hi guys
I have a matrix.
here the first column is date and others columns are data. for eg.
I have data like this.
05/04/2018 15 54 87
06/04/2018 48 NaN 8
07/04/2018 NaN NaN NaN
08/04/2018 NaN 8 NaN
09/04/2018 NaN NaN NaN
what i want is
05/04/2018 15 54 87
06/04/2018 48 NaN 8
08/04/2018 NaN 8 NaN
hope you understand. !!! thanks in advance.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 5월 21일

1 개 추천

mask = all(isnan(YourArray),2);
YourArray(mask, :) = [];

댓글 수: 5

pruth
pruth 2018년 5월 21일
hi thanks for the reply but it will not delete any row since the first column is for date and time. I want to delete date and time also.
You said you want to delete only those rows which have all NaN values in it. Any row that has a non-NaN time and date does not have all NaN values in it.
You probably want
mask = all(isnan(YourArray(:,2:end),2);
YourArray(mask, :) = [];
pruth
pruth 2018년 5월 21일
I apologize if it confuses you. let me clarify. I have data like this.
05/04/2018 15 54 87
06/04/2018 48 NaN 8
07/04/2018 NaN NaN NaN
08/04/2018 NaN 8 NaN
09/04/2018 NaN NaN NaN
what i want is
05/04/2018 15 54 87
06/04/2018 48 NaN 8
08/04/2018 NaN 8 NaN
hope you understand. !!! thanks
Ameer Hamza
Ameer Hamza 2018년 5월 21일
@Walter's code given in comment should work. Although there is a little typo about the mismatch of parenthesis.
mask = all(isnan(YourArray(:,2:end)),2);
YourArray(mask, :) = [];
pruth
pruth 2018년 5월 21일
yes, it works. I corrected that already. thank you :)

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

추가 답변 (0개)

카테고리

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

태그

질문:

2018년 5월 21일

편집:

2018년 5월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by