MATLAB Answers

Naime
0

find Nan in cell

Asked by Naime
on 11 Jul 2019
Latest activity Commented on by madhan ravi
on 11 Jul 2019
Accepted Answer by KSSV
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 Comments

KALYAN ACHARJYA on 11 Jul 2019
Check here
madhan ravi
on 11 Jul 2019
Provide an another example, as I understand A should contain [] as many [] are observed in A1 ? Is that true?

Sign in to comment.

1 Answer

KSSV
Answer by KSSV
on 11 Jul 2019
Edited by KSSV
on 11 Jul 2019
 Accepted Answer

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 Comments

madhan ravi
on 11 Jul 2019
ismepty is a new function?
KSSV
on 11 Jul 2019
Such function do not exist.
Naime
on 11 Jul 2019
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?

Sign in to comment.