Double Variable Second order Differential Equation
Show older comments
I am attempting to solve a double mass-spring-damper system. I already solved for single mass using ode45. However I am unable to figure out how to use this with two variables and also solve a second order differential.
The Equation I used was
The function I used is shown below.
function dy=damped_spring_mass(F,m,D,w0,b,t,y)
x=y(1);
v=y(2);
dy=zeros(2,1);
dy(1)=v;
dy(2)=(F*sin(w0*t)-D*x-c*v)/m;
I used this function to in ode45 as shown below
y0=[0;0];
tspan=[0 30];
%% Spring constants
k1= 5;
k01 = 1;
k12 = 2;
c=0.1;
D1= k1+c*(k01+k12);
%% mass constants
m1=1;
%% Damper C0fficients
b1=3;
%% Force
F= 0.1;
w0=2;
%% Diff Eq and plot
[Td,Yd]=ode45(@(t,y) damped_spring_mass(F,m1,D1,w0,b1,t,y),tspan,y0);
plot(Td,Yd(:,1));
For a double mass system, I have two equations
The new constants are provided below
%% Spring constants
k2= 2;
k23 = 3;
k34 = 1;
c=0.1;
D2= k2+c*(k23+k34);
%% mass constants
m2=2;
%% Damper C0fficients
b2=5;
Any help would be greatly appreciated. If you need more information please let me know!
Accepted Answer
More Answers (1)
Merve Buyukbas
on 6 Apr 2021
0 votes
2 Comments
Shabeel Samad
on 9 Apr 2021
Edited: Shabeel Samad
on 9 Apr 2021
Sajawal Feroze
on 20 Apr 2022
https://www.mathworks.com/matlabcentral/answers/434127-how-to-solve-system-of-2nd-order-differential-equations-using-ode45
Categories
Find more on Ordinary Differential Equations 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!