find the cell nan or not

14 ビュー (過去 30 日間)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015 年 8 月 24 日
回答済み: Walter Roberson 2015 年 8 月 24 日
I am trying to check the cell is nan or not I have a cell array a = {'ddd_Dds_1_dffs'}
when i use like this cellfun(@isnan,a,'UniformOutput',false)
i am getting as [0 0 0 0 0.......]
How to use cell fun to get only logical 1 or 0, if it is nan then 1 or 0
Thank you

採用された回答

Walter Roberson
Walter Roberson 2015 年 8 月 24 日
cellfun(@(C) isnumeric(C) && any(isnan(C(:))), a)
for the case where you want to check whether the entry contains NaN anywhere. If you want to check to see whether the entry is a single NaN then
cellfun(@(C) isequaln(C, NaN), a)
You are getting the vector of results because strings are arrays of char and isnan() was testing each element of the array
In the situation where you know that each entry is either a string or else a NaN, then test
~cellfun(@ischar, a)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHypothesis Tests についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by