2DOF (ODE) response in MATLAB
조회 수: 17 (최근 30일)
이전 댓글 표시
Im trying to find the response to the 2DOF for the following system, ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283820/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283820/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283821/image.png)
initial conditions:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283822/image.png)
with the the following force applied to m2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283823/image.png)
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
답변 (1개)
Ameer Hamza
2020년 4월 12일
편집: Ameer Hamza
2020년 4월 12일
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
Ameer Hamza
2020년 4월 15일
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Digital Filter Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!