Separating Data through the position of NaN

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

 Accepted 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

2 Comments

Thank you for the answer but I want to distinguish the data through NaN's position.
Distinguish the data? What you mean by this? You have the indices of both numbers and Nan's, you have distinguished it.

Sign in to comment.

More Answers (0)

Asked:

on 5 Feb 2020

Commented:

on 5 Feb 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!