clc; clear variables;
x(1)=0;
tic
for i=1:500
x(i+1)=(x(i).^2)*0.5+4;
if abs((x(i+1)-x(i)))<=0.00000001
break
else
x(i)=x(i+1);
end
end
toc

 채택된 답변

Hiro Yoshino
Hiro Yoshino 2020년 1월 16일

0 개 추천

if abs((x(i+1)-x(i)))<=0.00000001
This condition is less likely to be met ... I think.

댓글 수: 1

DEV
DEV 2020년 1월 16일
thank you
I applied
max(abs(x(i+1)-x(i)))<=0.000001
Now it is working

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

DEV
2020년 1월 16일

댓글:

DEV
2020년 1월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by