Euler method and RK

9 ビュー (過去 30 日間)
fernando piedra
fernando piedra 2020 年 11 月 8 日
Hi i need to solve this equation P(t)= 24sin(35t), where intital values and final values are v_0=0m/s; S_0= 0.5; t_0=0s; t_1=1s; m=0.5; k=75; now i need to create a file where all inital values, another were precalcualtion are done and another that file that solve the equation by euler method and RK method. so far i know euler method and RK. then i need to loop them into a function that allows the user to choose the method of diffiretion. Please, i need some help getting this started. Many thanks in advance.
%EULERS METHOD
for i=1:n
y(i+1)=y(i)+0.25*f1(x(i),y(i));
x(i+1)=x(i)+0.25;
%RK 4TH ORDER
for j=1:n
k1=f3(x(j),y2(j));
k2=f3(x(j)+0.125,y2(j)+k1*0.125);
k3=f3(x(j)+0.125,y2(j)+k2*0.125);
k4=f3(x(j)+0.125,y2(j)+k3*0.125);
y2(j+1)=y2(j)+(0.25/6)*(k1+2*(k2+k3)+k4);
x(j+1)=x(j)+h;
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

タグ

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by