being equal two matrics contaning NaNs and numbers smaller than 1
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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,
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 2 Okt. 2012
Bearbeitet: Azzi Abdelmalek
am 2 Okt. 2012
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 Kommentare
Teja Muppirala
am 3 Okt. 2012
Recent versions now have the ISEQUALN function, which is exactly the same thing as ISEQUALWITHEQUALNANS except the name is much easier to type.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!