MATLAB: Data with NaN

nan

Hi
I´m having trouble plotting data that include NaNs. I load a data-matrix using textread. I want to skip plotting entries that are NaNs.
For example:
x=[4 2 NaN 9]
y=[3 5 7 8]
Now I want to plot x against y for the 1st, 2nd and last entries (skipping the third). Are tips how to do this?

Best Answer

If you wanted to keep a line connecting them:
I = ~isnan(x) & ~isnan(y);
plot(x(I),y(I))