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?

 채택된 답변

the cyclist
the cyclist 2014년 9월 23일

1 개 추천

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

댓글 수: 1

Mandeep
Mandeep 2014년 9월 23일
This works! Thanks and Infact it created rowIdexToRemove and show which Rows got removed.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 NaNs에 대해 자세히 알아보기

태그

질문:

2014년 9월 23일

댓글:

2014년 9월 23일

Community Treasure Hunt

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

Start Hunting!

Translated by