フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

variables problem , infinite loop

2 ビュー (過去 30 日間)
yasin
yasin 2013 年 10 月 31 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (2 件)

sixwwwwww
sixwwwwww 2013 年 10 月 31 日
編集済み: sixwwwwww 2013 年 10 月 31 日
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 2013 年 11 月 1 日
format long
id1=0.513709476164662
id2=0.513709476164661
id1=str2num(sprintf('%.14f',id1))
id2=str2num(sprintf('%.14f',id2))
id1==id2

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by