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!