Taylor and Euler Method for ODE

9 visualizaciones (últimos 30 días)
LoveMatlab
LoveMatlab el 2 de Dic. de 2016
Editada: Nusaybah Ar el 8 de En. de 2020
y'-sin(4t)=0 y(0)=-0.25. 1. Use Taylor method to solve up to t4 for 20 steps, h=0.1.
  1 comentario
James Tursa
James Tursa el 2 de Dic. de 2016
What have you done so far? What specific problems are you having with your code?

Iniciar sesión para comentar.

Respuesta aceptada

James Tursa
James Tursa el 2 de Dic. de 2016
MATLAB is a 0-based indexing language. So you can't have y(0) in your code. It will need to start at y(1).
y(1)= -0.25;
Also, you need to index into your t vector as t(i):
Dy(i)=sin(4*t(i));
  4 comentarios
Hanaa Yakoub
Hanaa Yakoub el 31 de Dic. de 2019
how do you do it for 20 steps if you are only going up to the fourth derivative?
Nusaybah Ar
Nusaybah Ar el 8 de En. de 2020
Editada: Nusaybah Ar el 8 de En. de 2020
I've attempted this question for the taylor method and can't seem to be getting an answer. How do i fix this code? Thanks.
h = 0.1; %Time Step
a = 0; %Starting t
b = 2; %Ending t
n = 20; %Number of Iterations
y(i) = -0.25; %Initial Condition
y1=sin(4*t)
y2=4*cos(4*t)
y3= -16*sin(4*t)
y4=-64cos(4*t)
for i = 0:h:2
y(i+1) = y(i) + y1*h + ((y2/factorial(2))*h.^2) +((y3/factorial(3))*h.^3)+(y4/factorial(4)*h.^4)
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by