Second order differential equation with large matrices
조회 수: 9 (최근 30일)
이전 댓글 표시
Greetings,
I am tryig to solve this differential equation M * q'' + K * q= - K_d * q' - K_p * (q - q_d) where M is a 15x15 matrix, q is 15x1 vector, K is a 15x15 matrix, K_d and K_p are 15x15 known matrices and q_d is a 15x1 vector which is also known. q'' is a second time derivative. Which solver is the most applicable for this equation? and is there way to solve this in a matrix form and not expand the whole equation. Thanks in advance.
댓글 수: 6
Torsten
2022년 12월 10일
편집: Torsten
2022년 12월 10일
One question guys. Let's say matrix M is not constant and is dependent on q, so at every time step M changes accordingly to the values of q calculated at previous time step (starting from initial condition q0). How can i incorporate that into the odesystem function for ode45 solver? Thank you in advance
By dividing through M (assuming M is non-singular):
q'' = M \ (- K * q - K_d * q' - K_p * (q - q_d) )
If M is singular, define M as mass-matrix for the ODE solver in the options-structure and use ode15s or ode23t instead of ode45.
채택된 답변
Sam Chak
2022년 12월 5일
SInce this is a linear system, if you have the Control System Toolbox, then you can manipulate the matrix differential equation and convert it to a State-Space Model, that is similar to the system of 1st-order differential equations as advised by @Torsten, and then run the simulation using the lsim() command.
The following example demonstrates a 2-DOF Mass-Spring-Damper System.
M = diag([1 1])
Kd = 2*diag([1 1])
Kp = 0.5*diag([1 1])
K = 0.5*diag([1 1])
Convert the system of ODEs to State-space Model:
where the state vector is defined as
% State matrix
A = [zeros(2) eye(2);
M\(-Kp-K) M\(-Kd)]
% Input matrix
% B = [zeros(2); M\Kp] % based on your original Kp*qd
B = [zeros(2); M\(Kp+K)] % modified to track desired qd
% Output matrix
C = [eye(2) zeros(2)]
% Feedforward matrix
D = 0;
sys = ss(A, B, C, D)
t = 0:0.02:20;
u1 = max(0,min(t-1,1)); % qd1
u2 = max(0,min(t-1,1)); % qd2
U = [u1; u2]; % qd array
lsim(sys, U, t)
% lsim(sys, U, t, x0) % Use this if there is a vector x0 of initial state values
grid on
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!