When I compare the position of an axis with a double array containing the exact same values, the comparison returns false. Below, I compare both using A == B
and isequal(A,B)
:
>> ax = gca;
>> ax.Position
ans =
0.0500 0.1000 0.9000 0.4250
>> comparePosArray = [0.0500 0.1000 0.9000 0.4250]
comparePosArray =
0.0500 0.1000 0.9000 0.4250
>> comparePosArray == ax.Position
ans =
1×4 logical array
0 1 0 0
>> isequal(comparePosArray, ax.Position)
ans =
logical
0
>> class(comparePosArray)
ans =
double
>> class(ax.Position)
ans =
double
I.e. both arrays contain double values. Both arrays are seemingly identical (I created the axis with those exact values, so I am certain that there is no small extra value, e.g. 1e-9 or so. Given that Matlab has not added it a posteriori). the A == B
claims that ONE value is the same, why? Why not all? Why does not isequal
return true?
If I use num2str()
and then strcmp()
, the comparison will return true.
All help is much appreciated.