Comparison among numbers, pls help!
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alcide Bertocco
am 14 Mai 2021
Bearbeitet: Adam Danz
am 14 Mai 2021
Good morning guys,
I have a strange issue with my matlab code.
I have two Matrix and I need to compare a specic row of the first matrix with a specific of the second one.
I know they are equal but I need matlab check it for me!
In the first step i defined the two matrixs and than I asked to check the equality. This second step is shwn in the figure below and I have already checkd they are numbers and not strings.

How it is possible ? How can I correct this problem?
TY in advance
2 Kommentare
Akzeptierte Antwort
Adam Danz
am 14 Mai 2021
Bearbeitet: Adam Danz
am 14 Mai 2021
The difference is likely due to round-off error due to floatling point representation
To test for equality while ignoring round-off error, instead of A==B or isequal(A,B),
abs(A-B) < 1e4*eps(min(abs(A),abs(B)))
References & Examples
- Recognize and Avoid Round-Off Errors
- How can I compare numbers for equality within a tolerance
- Increase Precision of Numeric Calculations
- Floating Points: IEEE Standard Unifies Arithmetic Model
- Floating Point Numbers
- Example
- Another example
- Exploring Rounding Errors in Matlab Using Extended Precision - article
- What Every Computer Scientist Should Know About Floating-Point Arithmetic
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Number Theory finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!