MATLAB: How to find the lowest and highest rows in a column vector which contain a value.

MATLABvector

So, I have a 20×1 vector (A) shown below. How would I find the row number for the lowest and highest row that contain a value? In the vector below the lowest would be row 6, and the highest would be row 17. Thanks.
A =
NaN
NaN
NaN
NaN
NaN
1
1
1
NaN
NaN
NaN
1
1
1
NaN
NaN
1
NaN
NaN
NaN

Best Answer

idx = ~isnan(A);
lowestRow = min(find(idx));
highestRow = max(find(idx));