MATLAB: How to delete entire row containing a certain value.

deleting rows

I am trying to delete all rows in matrix A that contain 'NaN' using the code below. A(any(isnan(A)),:)=[];
I used this code for A=[NaN 1 1; NaN 2 2; 1 NaN 1; 2 NaN 2], and the output for A was
A =
1 NaN 1
2 NaN 2
So the code successfully deleted the first two rows containing NaN, but not the last two. Why is this and how can I fix my code?

Best Answer

It works! Thank you.