Approximate solution for spring mass spring damper using backward (implicit),improved euler (predictir-corrector), central difference, and runge-kutta
이전 댓글 표시
Hi guys,
Im trying to solve the response for mass-spring-damper system using the following approximate methods:
Euler (backward difference)
improved euler (predictor-corrector)
Central difference
Runge-Kutta
I already developed code that does forward difference but i dont know how to modify it to cover the rest that is mentioned above.
I would appriciate it if you could helo me with above methods. the equation of motion for the mentiioned system is:

and my code is attached
dz1dt=@(t,z1,z2) (z2); %coverting 2nd degree ode into 2 1st order
dz2dt=@(t,z1,z2) (-2*Z*omegan*z2-omegan^2*z1);
z1_0=1; %initial condition
z2_0=0;
a=0; %time start
b=10;
h=0.01; %step size
z1i=z1_0;
z2i=z2_0;
ti=a;
iter=1;
zout(1,1:2)=[z1i,z2i];
tout(1)=a;
while ti<b;
z1ip1=z1i+h*dz1dt(ti,z1i,z2i) %solving used forwarde diff
z2ip1=z2i+h*dz2dt(ti,z1i,z2i)
tip1=a+iter*h;
zout(iter+1,1:2)=[z1i,z2i];
tout(iter+1,1)=tip1;
iter=iter+1;
ti=tip1;
z1i=z1ip1;
z2i=z2ip1;
end
figure()
plot(tout,zout(:,1))
댓글 수: 4
darova
2020년 4월 1일
- improved euler (predictor-corrector)
Do you have any attempts on this? What kind of help do you need?
Faraz Vossoughian
2020년 4월 1일
darova
2020년 4월 1일
Do you have formulas?
Faraz Vossoughian
2020년 4월 1일
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!