How to filter Rows based on Values in them

I Like to Remove rows of data where I have 'NaN' and preserve the rest of the data in the original variable.
Data:
NaN NaN Nan 1 2 4;
3 4 5 Nan Nan 2;
4 5 6 7 8 1;
2 5 7 8 9 2;
NaN 2 4 5 9 1;
The final Data should look like as it removed NaN lines
4 5 6 7 8 1;
2 5 7 8 9 2
What code should I use?

 Akzeptierte Antwort

the cyclist
the cyclist am 23 Sep. 2014

1 Stimme

rowIndexToRemove = any(isnan(Data),2);
Data(rowIndexToRemove,:) = [];

1 Kommentar

Mandeep
Mandeep am 23 Sep. 2014
This works! Thanks and Infact it created rowIdexToRemove and show which Rows got removed.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Gefragt:

am 23 Sep. 2014

Kommentiert:

am 23 Sep. 2014

Community Treasure Hunt

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

Start Hunting!

Translated by