Euler method and RK
조회 수: 8 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numerical Integration and Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!