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.......

댓글 수: 3

Ali Asghar
Ali Asghar 2018년 10월 14일
i = 0:0.5:1 initial condition is x(0) = 2
Kevin Chng
Kevin Chng 2018년 10월 14일
Have you tried out any code?
Stephen23
Stephen23 2018년 10월 16일
Earlier question:
@Ali Asghar: remember to accept the answer that best helped to resolve your question.

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

답변 (1개)

Image Analyst
Image Analyst 2018년 10월 14일

0 개 추천

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.

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

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2017b

태그

아직 태그를 입력하지 않았습니다.

질문:

2018년 10월 14일

댓글:

2018년 10월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by