필터 지우기
필터 지우기

erasing all the rows that begin with NaN

조회 수: 1 (최근 30일)
Sabbas
Sabbas 2012년 7월 9일
I have a cell matric.
The first two columns of this matrix are
[1x28 char] [ NaN]
[ NaN] [ NaN]
'MART' 'TOTATRIA'
'PREGORY' 'TOSTE'
[ NaN] [ NaN]
My goal is to erase these rows which have as a first element NaN
In the above example I want to erase row2 and the last one
thanks

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 7월 9일
just
out = A(~cellfun(@(x)all(isnan(x)),A(:,1)),:)

추가 답변 (2개)

Thomas
Thomas 2012년 7월 9일
If A is your input cell matrix
out=cellfun(@isnan,A(:,1),'UniformOutput',false)
count=cellfun(@(x)any(x==1),out);
A(~count,:)
  댓글 수: 10
Sabbas
Sabbas 2012년 7월 9일
편집: Sabbas 2012년 7월 9일
it works for me when I choose the first two columns. But not when I use the whole matrix
Sabbas
Sabbas 2012년 7월 9일
편집: Sabbas 2012년 7월 9일
I used
count=cellfun(@(x)any(x==1),out);
A(count==1,:)=[]
and it seems to work
could you plese verify that the code is equivalent to the one you provided?
thanks

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


Jan
Jan 2012년 7월 9일
편집: Jan 2012년 7월 9일
A(cellfun(@(x) isequalwithequalnans(x, NaN), C), :)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by