Hi, in my cell array X, I would like to drop all rows where the value of the 4th column is NaN (the new cell array is Y).
I am trying this:
Y = X(~any(cellfun(@isnan,X(:,4),'UniformOutput',false),2),:)
It returns the following error: Undefined function 'any' for input arguments of type 'cell'.
How do I have to change the code?

댓글 수: 1

Stephen23
Stephen23 2016년 9월 13일
Not enough information: what is the cell array? What size are the arrays inside the cell array? Are all cell contents numeric?

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

 채택된 답변

Stephen23
Stephen23 2016년 9월 13일
편집: Stephen23 2016년 9월 13일

1 개 추천

Making some guesses here, but this might do what you want:
Y = X(cellfun(@(x)any(isnan(x)),X(:,4)),:)

댓글 수: 2

phlie
phlie 2016년 9월 13일
편집: phlie 2016년 9월 13일
Thank you for answering my incomplete question anyway. Your code works, but it does the exact opposite of what I wish to do. With a tilde before isnan, it works as I was hoping :)
If the content of each cell is a scalar, you could even do this:
Y = X(~cellfun(@isnan,X(:,4)),:)

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

추가 답변 (0개)

카테고리

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

질문:

2016년 9월 13일

댓글:

2016년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by