Reputation: 165
The function ISEQUAL works fine with numbers and inf, but whenever a NaN appears in the array, it screws everything. I am looking for a simple way to compare two arrays containing NaN's (which for me is good enough to say that NaN==NaN). I was thinking of something like a bitwise comparison, but I don't know how to get to the exact bit representation of Matlab.
Any ideas?
Upvotes: 2
Views: 424
Reputation: 74940
If you want to know whether the arrays are equal,
tf = isequaln(A,B);
If you want to know whether the elements are equal (with NaN==NaN), you could do
nanA = isnan(A);
nanB = isnan(B);
tfByElement = A==B | nanA & nanB;
Upvotes: 5