2DOF (ODE) response in MATLAB
17 views (last 30 days)
Show older comments
Im trying to find the response to the 2DOF for the following system,
initial conditions:
with the the following force applied to m2
I obtained the eqm, and tried to solve the ODE's using dsolove however the code doesnt work, Im not sure if this is because of wrong equation of motion, or Im taking the wrong approach. Also im wondering how to implement lsim command to solve this problem. I would appriciate the help. Thanks very much!
% finding force
F0=5;
T=1;
t=0:0.01:1;
F1=-F0*(t/T)+F0;
plot(t,F1)
hold on
t2=1:0.01:2
F2=F0*(t2/T)-F0;
plot(t2,F2)
hold on
t3=3:0.01:10
F3=F0;
F2=[F1,F2,F3];
hold off
% solving problem
syms x1(t) x2(t) F1 F2
m1=1;m2=2;c1=0;c2=0;k1=4;k2=4;k0=0.5;F1=F1;F2=F3;
eq1=F2==m2*(diff(x2,2)-diff(x1,2))+c2*(diff(x2,1)-diff(x1,1))+k2*(x2-x1);
eq2=F1==m1*diff(x1,2)+c1*diff(x1,1)+k1*x1;
Dx1=diff(x1);Dx2=diff(x2);
[X1(t),X2(t)]=dsolve([eq1 eq2],[x1(0)==0,Dx1(0)==0,x2(0)==0,Dx2(0)==0]);
t1=0:0.01:10;
Force=F2;
x1=subs(X2(t),{t,F2,F1},{t1,Force,0})
plot(t,X2(t));legend('X1(t)','X2(t)')
0 Comments
Answers (1)
Ameer Hamza
on 12 Apr 2020
Edited: Ameer Hamza
on 12 Apr 2020
In MATLAB, ode45 solver can be used to solve such equations numerically. Since you are solving these equations symbolically, the following correct the error in your code
% finding force
F0=5;
T=1;
t=0:0.01:1;
F1=-F0*(t/T)+F0;
plot(t,F1)
hold on
t2=1:0.01:2
F2=F0*(t2/T)-F0;
plot(t2,F2)
hold on
t3=3:0.01:10;
F3=F0;
F2=[F1,F2,F3];
hold off
% solving problem
syms x1(t) x2(t) F1 F2
m1=1;m2=2;c1=0;c2=0;k1=4;k2=4;k0=0.5;F1=F1;F2=F3;
eq1=F2==m2*(diff(x2,2)-diff(x1,2))+c2*(diff(x2,1)-diff(x1,1))+k2*(x2-x1);
eq2=F1==m1*diff(x1,2)+c1*diff(x1,1)+k1*x1;
Dx1=diff(x1);Dx2=diff(x2);
[X1(t),X2(t)]=dsolve([eq1 eq2],[x1(0)==0,Dx1(0)==0,x2(0)==0,Dx2(0)==0]);
t1=0:0.01:10;
Force=F2;
x1(t)=subs(X2(t),{t,F2,F1},{t1,Force,0});
x2(t)=subs(X2(t),{t,F2,F1},{t1,Force,0});
plot(t1,x1(t), t1,x2(t));legend('X1(t)','X2(t)')
But the two variables x1, and x2 overlap. I am not sure if this is correct solution. If you can give the mathematical form of your equations, I can see if your equations are correctly implemented.
6 Comments
Ameer Hamza
on 15 Apr 2020
Glad to be of help. If you can apply ode45, then you already have knowledge about the state-space representation of your system of ODE.
See Also
Categories
Find more on Digital Filter Analysis 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!