2nd order ODE system
显示 更早的评论
The system is a 2DOF mechanical mass spring damper which is free on one end. The system recieves an input on the free end for a short period of time.
I am trying to solve my system for the equations in X and I am particularly interested in x1(t) and x2(t).
When solving without the conditions dsolve returns a very long function in terms of t and z, I do not know what z is.
clear all
clc
syms x1(t) x2(t) x3(t) x4(t) f2
m1=6.5; %effective mass of the person
m2=2; %mass of the secondary body
c1=60; %effective damping of the person
c2=80; %damping of the second body
k1=150; %effective stiffness of the person
k2=200; %stiffness of the second body
f2 = rectangularPulse(0,.05,5); %impulse input on the secondary body
X = [x1(t); x2(t); x3(t); x4(t)]; %column vector of the states where x1(t) is the position of the person x2(t) is the position of the second body
%x3(t) is the velocity of the first body and x4(t) is the velocity of the second body
A = [0 0 1 0;
0 0 0 1;
-(k1+k2)/m1 k2/m1 -(c1+c2)/m1 c2/m1;
k2/m2 -k2/m2 c2/m2 -c2/m2]; %the system matrix for how the system will behave
B = [0; 0; 0; 1/m2]; %input matrix for how the input affects the system
eqns = diff(X) == A*X + f2*B; %setting the differential system to a variable
cond1 = x1(0)==2; %initial position of the person
cond2 = x2(0)==3; %initial position of the second body
cond3 = x3(0)==6; %initial velocity of the person
cond4 = x4(0)==7; %initial velocity of the second body
conds = [cond1;cond2;cond3;cond4]; %the conditional column vector
[x1Sol(t), x2Sol(t), x3Sol(t), x4Sol(t)] = dsolve(eqns, conds); %setting up the dsolve function to return the equations as done in another forum
x1Sol(t) = simplify(x1Sol(t)) %returning the simplified x1Sol
x2Sol(t) = simplify(x2Sol(t)) %returning the simplified x2Sol
Currently the system coefficients (m1,m2,c1 etc.) and the conditional inputs are set as random placeholders.
I would like the code to work for a symbolic input of f2 as well, as what I am modeling is not simply an impulse.
I just need a useful output for x1Sol(t) and x2Sol(t)
Many thanks,
Carter
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 3DOF 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!