Why isn't the numerical value assigned by matlab verified using == function.
Ältere Kommentare anzeigen

I have calculated the value for R using my code which has assigned 0.0094 but if I try to verify using == function , it shows logical zero.
I had used format short but evidently isn't doing much.
what should I change here.
1 Kommentar
"I had used format short but evidently isn't doing much."
FORMAT changes how numeric data are displayed, just as the FORMAT documentation explains.
FORMAT does not change what data are stored in memory. What numeric data are stored in memeory and how they are displayed are two different things: mixing them up like you are doing will not make working with numeric data easy.
"what should I change here."
Either use ISMEMBERTOL or compare the absolute difference against some tolerance (of your choice):
abs(R-0.0094)<0.00005
Akzeptierte Antwort
Weitere Antworten (1)
Divyajyoti Nayak
am 8 Aug. 2024
Bearbeitet: Divyajyoti Nayak
am 8 Aug. 2024
0 Stimmen
Hi @Yogesh, the 'format' command does not change the precision of your variables. It only changes the format in which the output is displayed. The actual value of R is unchanged.

1 Kommentar
Yogesh
am 8 Aug. 2024
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!