Approximate Equality in Matlab

343 visualizaciones (últimos 30 días)
Ganesh Kini
Ganesh Kini el 22 de Abr. de 2020
Respondida: David Hill el 22 de Abr. de 2020
So i have two values
A = 1.69 and B = 1.8
A = 2.1 and B = 2.4
How do i show it that they are approximately equal without using round
are there any relational operators that i can use ?

Respuestas (2)

Walter Roberson
Walter Roberson el 22 de Abr. de 2020
if abs(A-B) < tolerance
See also ismembertol()
There is no operator symbol for approximate equality -- no A?=B or anything like that.

David Hill
David Hill el 22 de Abr. de 2020
tol=.2;%whatever you want
abs(B-A)<tol;

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by