Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

variables problem , infinite loop

2 visualizzazioni (ultimi 30 giorni)
yasin
yasin il 31 Ott 2013
Chiuso: MATLAB Answer Bot il 20 Ago 2021
when I push ctrl+c , I see id1 and id2.
id1 0.513709476164662
id2 0.513709476164661
if they are equal ,the loop will end how can delete last numbers after comma

Risposte (2)

sixwwwwww
sixwwwwww il 31 Ott 2013
Modificato: sixwwwwww il 31 Ott 2013
Dear Yasin, you can use
round
or
floor
or
ceil
or
format
for this purpose. Also don't use condition of equality to control loop instead use some tolerance value like this:
while id1 - id2 < 1e-5
...
...
...
end
It will work better

Azzi Abdelmalek
Azzi Abdelmalek il 1 Nov 2013
format long
id1=0.513709476164662
id2=0.513709476164661
id1=str2num(sprintf('%.14f',id1))
id2=str2num(sprintf('%.14f',id2))
id1==id2

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by