code of euler's method
이전 댓글 표시
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
Sara
2014년 5월 22일
What's the expected result? What are the functions you're trying to solve?
채택된 답변
추가 답변 (3개)
SkyRazor
2014년 5월 23일
0 개 추천
hello, could you please post your equation and give us some explanations?
ahmed abdelmageed
2020년 5월 4일
0 개 추천
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
2021년 7월 28일
0 개 추천
%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);
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!