필터 지우기
필터 지우기

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