# why 2 vectors are not the same in matlab?

I have 2 vectors:

a = 1.0e-04*[0.110000000000000   0.140000000000000   0.140000000000000   0.140000000000000];
b =         [0.000011000000000   0.000014000000000   0.000014000000000   0.000014000000000];


by look at by eyes, it seems similar; but when I use this command:

a == b


then I got:

ans =
1×4 logical array
0   0   0   0


The expectation is:

ans =
1×4 logical array
1   1   1   1


Does anyone knows what wrong with this command in the matlab?

Thank you.

• See this SO question. – Peter K. May 17 '17 at 20:37
• One way to fix it can be abs(a-b)<1e-15. – msm May 18 '17 at 0:14

• @phucnguyen That negative sign in front of one of the numbers should make you suspect that these are not actually zeros. See also the documentation for the format command.. – MBaz May 17 '17 at 22:46