MATLAB: Separating Data through the position of NaN

data sortnan

Hello
I have a data file in which data is logged as command input and sensor output.
For ex:
1,NaN,NaN,2,3,4,5,6,7
10,40,30,NaN,NaN,NaN,NaN,NaN,NaN
Data logged as (data,NaN,NaN,data,data,data,data,data,data) is sensor output and data logged as (data,data,data,NaN,NaN,NaN,NaN,NaN,NaN) is command input.
The file has huge mixed data and I want to process the sensor output and command input differently.
Is there any particular command (for 2018b) to sort data or any other alternative?
Regards

Best Answer

YOu can get the locations of NaN's using isnan. Once you have the indices of NaN's you can remove them.
A = [1,NaN,NaN,2,3,4,5,6,7] ;
idx = isnan(A) ; % get the indices
A(idx) = [] ; % remove the NaN's