find Nan in cell

5 次查看(过去 30 天)
NA
NA 2019-7-11
I want to find nan element in A,
A={[],[],[31],[2,1]}; %first case
A1={[],[2],[3],[6]}% second case
I used this code, but did not give me the correct answer
P=cellfun(@(x) isnan(x),A,'UniformOutput',false);
after that, check if first and second elemnt is nan, put A as [];
aswer should be
A=[] % first case
A1={[],[2],[3],[6]}% second case
  2 个评论
madhan ravi
madhan ravi 2019-7-11
Provide an another example, as I understand A should contain [] as many [] are observed in A1 ? Is that true?

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2019-7-11
编辑:KSSV 2019-7-11
Use isempty..not isnan
A={[],[],[31],[2,1]}; %first case
A1={[],[2],[3],[6]}% second case
P=cellfun(@(x) isempty(x),A,'UniformOutput',false)
  3 个评论
KSSV
KSSV 2019-7-11
Such function do not exist.
NA
NA 2019-7-11
A={[],[],[31],[2,1]};
P=cellfun(@(x) isempty(x),A,'UniformOutput',false);
if P{1}==1& P{2}==1
A=[];
end
is it a correct way to do this?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by