isnan cellfun and dropping rows

3 ビュー (過去 30 日間)
phlie
phlie 2016 年 9 月 13 日
コメント済み: Stephen23 2016 年 9 月 13 日
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 日
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 :)
Stephen23
Stephen23 2016 年 9 月 13 日
If the content of each cell is a scalar, you could even do this:
Y = X(~cellfun(@isnan,X(:,4)),:)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by