code of euler's method
Mostrar comentarios más antiguos
Hi, i follow every protocol steps for euler's method, but my results are too increased and they are not correct. Anyone could see if i´m doing anything wrong? i think it happens because my derivatives are floating too much.
1 comentario
Sara
el 22 de Mayo de 2014
What's the expected result? What are the functions you're trying to solve?
Respuesta aceptada
Más respuestas (3)
SkyRazor
el 23 de Mayo de 2014
0 votos
hello, could you please post your equation and give us some explanations?
ahmed abdelmageed
el 4 de Mayo de 2020
0 votos
function E=euler(f,a,b,ya,M)
h=(b-a)/M;
Y=zeros(1,M+1);
T=a:h:b;
Y(1)=ya;
for j=1:M
Y(j+1)=Y(j)+h*f(T(j));
end
E=[T' Y'];
end
Sandip Das
el 28 de Jul. de 2021
0 votos
%Published in 19th july 2021
%Sandip Das
clc
clear all
dydt=input('\n Enter the function : ');
x0=input('\n Enter initial value of x : ');
y0=input('\n Enter initial value of y : ');
xn=input('\n Enter the final value of x: ');
h=input('\n Enter the step length h: ');
i=0;
while i<xn
tempy=y0+h*dydt(x0,y0);
tempx=x0+h;
x0=tempx;
y0=tempy;
i=i+h;
end
fprintf('The value of y at t=%f is %f \n',x0,y0);
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!