Delete rows with NaN for a cell array

조회 수: 10 (최근 30일)
Rooy
Rooy 2013년 6월 26일
댓글: YING CONG XIAO 2021년 4월 21일
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 2013년 6월 26일
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 (%)'

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

채택된 답변

Tom
Tom 2013년 6월 26일
A(any(cellfun(@(x) any(isnan(x)),A),2),:) = [];

추가 답변 (1개)

Andrei Bobrov
Andrei Bobrov 2013년 6월 26일
편집: Andrei Bobrov 2013년 6월 26일
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),:);
  댓글 수: 4
Rooy
Rooy 2013년 6월 26일
Thank you for your great help
YING CONG XIAO
YING CONG XIAO 2021년 4월 21일
hi Andrei,
how to specify the range in this fun:
out = A(any(cellfun(@(x)any(~isnan(x)),A),2),:);

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

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by