I'm trying to solve two second order differntial equations.

1 view (last 30 days)
I am a MatLab novice.
I'm trying to solve simultaneous 2nd order differential equations for a spring mass damper system using ode45.
The code I have written so far is below:
function ODE2 clear;clc; timerange=[0 5]; initialvalues=[5 10]; [t,y]=ode45(@smd,timerange,initialvalues);
plot(t,y(:,1))
function spg=smd(t,y) ms=100; mu=1; ks=20000; ku=1; zeta=0.45; cs=zeta*2*(sqrt(ks*ms)) cu=1;
spg=[y(2);-((cs/ms)*y(2))-((ks/ms)*y(1))],
[y(4);((cs/mu)*y(2))-((cu/mu)*y(3))-((ks/mu)*y(1))-((ku/mu)*y(4))];
The code will solve the first equation, if I use % to blank out the second.
Any help would be valuable as I seem to be getting no where.
Would a method using matrices be more appropriate?
Thanks
Paul

Answers (0)

Community Treasure Hunt

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

Start Hunting!