MATLAB Answers

Delete rows with NaN for a cell array

조회 수: 88(최근 30일)
Rooy
Rooy 26 Jun 2013
I want to remove the rows that have NaN and still keep the dimension of the array intact.
[ NaN] [ NaN] [ NaN] [ NaN]
[ NaN] [ NaN] [ NaN] [ NaN]
'Total RADIO Drops' 'Total Drops' 'CC DCR (%)' 'RADIO DCR (%)'
Above is just an example, I have over a thousand rows.
The only problem I have now is removing rows which have NaN and string together
Thank you

  댓글 수: 1

Rooy
Rooy 26 Jun 2013
Is there a way to delete the rows which have strings and Nan mixed together ?
[ 'A'] [ NaN] [ NaN] [ NaN]
'Total RADIO Drops' 'Total Drops' 'CC DCR (%)' 'RADIO DCR (%)'

로그인 to comment.

채택된 답변

Tom
Tom 26 Jun 2013
A(any(cellfun(@(x) any(isnan(x)),A),2),:) = [];

  댓글 수: 1

Rooy
Rooy 26 Jun 2013
Thank you, it works

로그인 to comment.

More Answers (1)

Andrei Bobrov
Andrei Bobrov 26 Jun 2013
Andrei Bobrov 님이 편집함. 26 Jun 2013
A - your cell array
out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:);
ADD
out = A(all(cellfun(@(x)any(~isnan(x)),A),2),:);

  댓글 수: 3

Rooy
Rooy 26 Jun 2013
That works thank you, is there a way to delete the rows which have strings and Nan mixed together ?
Andrei Bobrov
Andrei Bobrov 26 Jun 2013
see ADD part in my answer
Rooy
Rooy 26 Jun 2013
Thank you for your great help

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by