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