I need your help. y'(t) = -30*y+30*t^2+2*t; y(0)=1, & exact solution is y(t)=e^-30*x +x^2. i can't understand what is different b/w kr4 plotting & its error . i need both graph n error please send me code.
Mostrar comentarios más antiguos
function rungekutta123
h = 0.05;
t = 0;
w = 1;
fprintf('Step 0: t = %12.8f, w = %12.8f\n', t, w);
for i=1:50
k1 = h*f(t,w);
k2 = h*f(t+h/2, w+k1/2);
k3 = h*f(t+h/2, w+k2/2);
k4 = h*f(t+h, w+k3);
w = w + (k1+2*k2+2*k3+k4)/6;
t = t + h;
fprintf('Step %d: t = %6.4f, w = %18.15f\n', i, t, w);
end
%%%%%%%%%%%%%%%%%%
function v = f(t,y)
v = -30*y+30*t^2+2*t;
2 comentarios
jamila nizamani
el 2 de Feb. de 2014
Image Analyst
el 2 de Feb. de 2014
Please read this: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup and fix your formatting.
Respuesta aceptada
Más respuestas (1)
Nurcan
el 22 de Abr. de 2024
0 votos
y(t)=f(t, y(t)) y(t0)=y0 tE[t0, T] f(t,y)=-y/(2*t)+t^2 t0=1 T=2 y0=1
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!