Approximate solution for spring mass spring damper using backward (implicit),improved euler (predictir-corrector), central difference, and runge-kutta
Show older comments
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 Comments
darova
on 1 Apr 2020
- improved euler (predictor-corrector)
Do you have any attempts on this? What kind of help do you need?
Faraz Vossoughian
on 1 Apr 2020
darova
on 1 Apr 2020
Do you have formulas?
Faraz Vossoughian
on 1 Apr 2020
Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!