being equal two matrics contaning NaNs and numbers smaller than 1

조회 수: 1 (최근 30일)
Hi all,
I have two matrics e.g. "a" & "b", which contains some "NaN" elements and numbers less than 1.
a=[NaN 0.4539 0.4532; NaN 0.4536 NaN]; b=[NaN 0.4533 0.4538; NaN 0.4531 NaN];
I want to see if "a" and "b" are equal with NaNs values ? the desired decimal places is 3.
How can I write such program?
thanks in advance,

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 2일
편집: Azzi Abdelmalek 2012년 10월 2일
a=round(a*1000)/1000;
b=round(b*1000)/1000;
a(isnan(a))=0;
b(isnan(b))=0;
test=all(all((a==b)))
% if test =1 then a=b
  댓글 수: 4
Azzi Abdelmalek
Azzi Abdelmalek 2012년 10월 2일
the answer isequalwithequalnans(a,b) was suggested and deleted.
Teja Muppirala
Teja Muppirala 2012년 10월 3일
Recent versions now have the ISEQUALN function, which is exactly the same thing as ISEQUALWITHEQUALNANS except the name is much easier to type.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by