need help in matlab coding

1 次查看(过去 30 天)
Ali Asghar
Ali Asghar 2018-10-14
评论: Stephen23 2018-10-16
How do I write coding for
x(i+1) = x(i) + 0.05(2*x(i) - t);
for i= 0:0.05:1
x(0) = 2.
For 1st iteration t = 0. For 2nd iteration t=0.05. For 3rd iteration t=0.1 and so on....
The answer will be: 2.2, 2.4175, 2.6542.......

回答(1 个)

Image Analyst
Image Analyst 2018-10-14
This works:
x(1) = 2;
t = 0:0.05:1
for k = 1 : length(t) - 1
x(k+1) = x(k) + 0.05 * (2 * x(k) - t(k));
end
% Show in command window:
x
  2 个评论
Ali Asghar
Ali Asghar 2018-10-16
thank you very much dear
Image Analyst
Image Analyst 2018-10-16
I'm not sure if you will get any more answers after all this time, so do you want to go ahead and "Accept this answer"? Thanks in advance.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

尚未输入任何标签。

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by