MATLAB: Isolate data elements out of a column on NaNs

arrayindexingMATLABnan

I have a large column of mostly "NaN" but it does periodically include actual data. Is there a way I can extract those data to form another vector?

Best Answer

a=[0 nan 1 nan];
b=a(~isnan(a))