MATLAB: Delete nan values and the corresponding value in another array

arraynan

I have three arays: I want to plot B(x axis) and C(y axis).if there is a nan in any of A,B or C that cell should be deleted with its corresponding cells in other arrays.
A=[ nan 2 3; 4 3 nan; 5 3 2] B=[ 9 8 7 ;6 nan 5;6 5 8] C=[3 4 nan;4 3 2;5 3 2]
answer: B=[nan 8 nan;6 nan nan;6 5 8] C=[nan 4 nan;4 nan nan;5 3 2]

Best Answer

nanIdx = find( isnan(A) | isnan(B) | isnan(C) );
A(idx) = NaN; B(idx) = NaN; C(idx) = NaN