fuzzyCompare

Compares two floating point values and returns true if they are considered equal, false otherwise
301 descargas
Actualizado 14 jun 2012

Ver licencia

Compares two floating point values and returns true if they are considered equal, false otherwise. Inspired by Qt's qFuzzyCompare function. Two floating point variables that should in theory be equal, might not always be equal, due to mthe finite number of bits that a computational device uses to store and operate on values.

Ex:
num = 7;
sqrtd = sqrt(num);
sqrtd(2) = sqrt(sqrtd(1));
sqrtd(3) = sqrt(sqrtd(2))
prods(1) = sqrtd(end);
prods(2) = prods(1)^2;
prods(3) = prods(2)^2
finalNum = prods(3)^2
num==finalNum %This is false, though they should be the same
fuzzyCompare( num, finalNum ) %this is true

Citar como

Ivar Eskerud Smith (2024). fuzzyCompare (https://www.mathworks.com/matlabcentral/fileexchange/37160-fuzzycompare), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2012a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versión Publicado Notas de la versión
1.0.0.0