Borrar filtros
Borrar filtros

need help in matlab coding

1 visualización (últimos 30 días)
Ali Asghar
Ali Asghar el 14 de Oct. de 2018
Comentada: Stephen23 el 16 de Oct. de 2018
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 comentarios
Kevin Chng
Kevin Chng el 14 de Oct. de 2018
Have you tried out any code?
Stephen23
Stephen23 el 16 de Oct. de 2018
Earlier question:
@Ali Asghar: remember to accept the answer that best helped to resolve your question.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 14 de Oct. de 2018
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 comentarios
Ali Asghar
Ali Asghar el 16 de Oct. de 2018
thank you very much dear
Image Analyst
Image Analyst el 16 de Oct. de 2018
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by