samedi 22 août 2015

Matlab script does not evaluate valid if construction

I have a 2D point vectorA and a rectangle with boundaries vectorX and vectorY. Following MWE represents my MATLAB code to check whether the point lies on the four consecutive boundaries:

vectorA=[1.6667 2];
vectorX=[0 1.6667];
vectorY=[2 3.3333]
if vectorA(1)==vectorX(1)
    disp('XL')
end
if vectorA(1)==vectorX(2)
    disp('XU')
end
if vectorA(2)==vectorY(1)
    disp('YL')
end
if vectorA(2)==vectorY(2)
    disp('YU')
end

I encountered a case for which the function did not detect that a given coordinate lied on a boundary. I printed the internal values of the variables and although I had if 1.6667==1.6667, that if was not evaluated.

Manually executing the consecutive calculations of my script works fine (including 1.6667==1.6667 which yields 1), but executing the script gives a wrong result. Where can I search for the reason for this strange behaviour?

Aucun commentaire:

Enregistrer un commentaire