find Nan in cell

조회 수: 4 (최근 30일)
NA
NA 2019년 7월 11일
댓글: madhan ravi 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
KALYAN ACHARJYA
KALYAN ACHARJYA 2019년 7월 11일
Check here
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