MATLAB: The polyarea function gives the wrong area

MATLABpolyarea

<<
>>
Hi, I have a question with the polyarea function
x = [0 3 3 0 0 1 1 2 2 1]; y = [0 0 3 3 0 1 2 2 1 1];
With this curve the value it gives is 8, which is correct
However I made a very similar curve
x = [0 0.4258 0.4258 0 0.009 0.4168 0.4168 0.009 0.009]; y = [0 0 0.1807 0.1807 0 0.009 0.009 0.1717 0.1717 0.009];
and the value it gives is polyarea (x, y) -> 0.1433. And the value that should give is 0.010593
someone knows why ?

Best Answer

I think MATLAB result is right, your expectation is wrong.
Check area
>> 0.1807*0.4258-(0.1807-2*0.009)*(0.4258-2*0.009)
ans =
0.010593000000000
>>
which is the same than MATLAB