Create a MATLAB code to convert Equations of Motion for Multi DOF system (2nd Order ODEs with multiple Variables) into matrix form(Coefficient Matrices)
I got 6 Equations of Motion (second order ODEs with 6 independent variables) for a 6 DOF system by using the following Code:-
clear all;
clc;
syms L T P D M1 M2 I1 I2 x1(t) x2(t) x3(t) x4(t) x5(t) x6(t) t K1 K2 K3 K4 K5 K6 C1 C2 C3 C4 C5 C6 a b c d e f1 f2 f3 f4 f5 f6;
f1 = (M1*(diff(x1,t,2))+2*(C1+C3)*diff(x1,t)-2*C3*diff(x4)+2*(K1+K3)*x1-2*K3*x4)
f2 = (M1*(diff(x2,t,2))+2*(C2+C4)*diff(x2,t)-2*C4*diff(x5)+2*(K2+K4)*x2-2*K4*x5)
f3 = (I1*(diff(x3,t,2))+2*(C1*b^2+C2*a^2+C3*c^2+C4*e^2)*diff(x3,t))-2*(C3*c*d+C4*e^2)*diff(x6)+2*(K1*b^2+K2*a^2+K3*c^2+K4*e^2)*x3-2*(K3*c*d+K4*e^2)*x6
f4 = (M2*(diff(x4,t,2))-2*C3*diff(x1,t)+2*C3*diff(x4)-2*K3*x1+2*K3*x4)
f5 = (M2*(diff(x5,t,2))-2*C4*diff(x2,t)+2*C4*diff(x5)-2*K4*x2+2*K4*x5)
f6 = (I1*(diff(x6,t,2))+2*(C3*d^2+C4*e^2)*diff(x6,t))-2*(C3*c*d+C4*e^2)*diff(x3)+2*(K3*d^2+K4*e^2)*x6-2*(K3*c*d+K4*e^2)*x3
U can see that all Mass Coefficients are with second order derivates only, Damping(C) terms with single order derivates and Stiffness(K) terms with zero order derivates. In state space Matrix form, it can be seen as [M][Ẍ]+[C][ẋ]+[K][x] = F.
Now, I need to convert these ODEs to State space form i.e. extract the M, C & K coefficients and make 6X6 matrices.
Presently, I am manually collecting all the terms and create the matrices. However, I want a matlab code which can auto populate the matrices.
Please create a code. Thank you.I got 6 Equations of Motion (second order ODEs with 6 independent variables) for a 6 DOF system by using the following Code:-
clear all;
clc;
syms L T P D M1 M2 I1 I2 x1(t) x2(t) x3(t) x4(t) x5(t) x6(t) t K1 K2 K3 K4 K5 K6 C1 C2 C3 C4 C5 C6 a b c d e f1 f2 f3 f4 f5 f6;
f1 = (M1*(diff(x1,t,2))+2*(C1+C3)*diff(x1,t)-2*C3*diff(x4)+2*(K1+K3)*x1-2*K3*x4)
f2 = (M1*(diff(x2,t,2))+2*(C2+C4)*diff(x2,t)-2*C4*diff(x5)+2*(K2+K4)*x2-2*K4*x5)
f3 = (I1*(diff(x3,t,2))+2*(C1*b^2+C2*a^2+C3*c^2+C4*e^2)*diff(x3,t))-2*(C3*c*d+C4*e^2)*diff(x6)+2*(K1*b^2+K2*a^2+K3*c^2+K4*e^2)*x3-2*(K3*c*d+K4*e^2)*x6
f4 = (M2*(diff(x4,t,2))-2*C3*diff(x1,t)+2*C3*diff(x4)-2*K3*x1+2*K3*x4)
f5 = (M2*(diff(x5,t,2))-2*C4*diff(x2,t)+2*C4*diff(x5)-2*K4*x2+2*K4*x5)
f6 = (I1*(diff(x6,t,2))+2*(C3*d^2+C4*e^2)*diff(x6,t))-2*(C3*c*d+C4*e^2)*diff(x3)+2*(K3*d^2+K4*e^2)*x6-2*(K3*c*d+K4*e^2)*x3
U can see that all Mass Coefficients are with second order derivates only, Damping(C) terms with single order derivates and Stiffness(K) terms with zero order derivates. In state space Matrix form, it can be seen as [M][Ẍ]+[C][ẋ]+[K][x] = F.
Now, I need to convert these ODEs to State space form i.e. extract the M, C & K coefficients and make 6X6 matrices.
Presently, I am manually collecting all the terms and create the matrices. However, I want a matlab code which can auto populate the matrices.
Please create a code. Thank you. I got 6 Equations of Motion (second order ODEs with 6 independent variables) for a 6 DOF system by using the following Code:-
clear all;
clc;
syms L T P D M1 M2 I1 I2 x1(t) x2(t) x3(t) x4(t) x5(t) x6(t) t K1 K2 K3 K4 K5 K6 C1 C2 C3 C4 C5 C6 a b c d e f1 f2 f3 f4 f5 f6;
f1 = (M1*(diff(x1,t,2))+2*(C1+C3)*diff(x1,t)-2*C3*diff(x4)+2*(K1+K3)*x1-2*K3*x4)
f2 = (M1*(diff(x2,t,2))+2*(C2+C4)*diff(x2,t)-2*C4*diff(x5)+2*(K2+K4)*x2-2*K4*x5)
f3 = (I1*(diff(x3,t,2))+2*(C1*b^2+C2*a^2+C3*c^2+C4*e^2)*diff(x3,t))-2*(C3*c*d+C4*e^2)*diff(x6)+2*(K1*b^2+K2*a^2+K3*c^2+K4*e^2)*x3-2*(K3*c*d+K4*e^2)*x6
f4 = (M2*(diff(x4,t,2))-2*C3*diff(x1,t)+2*C3*diff(x4)-2*K3*x1+2*K3*x4)
f5 = (M2*(diff(x5,t,2))-2*C4*diff(x2,t)+2*C4*diff(x5)-2*K4*x2+2*K4*x5)
f6 = (I1*(diff(x6,t,2))+2*(C3*d^2+C4*e^2)*diff(x6,t))-2*(C3*c*d+C4*e^2)*diff(x3)+2*(K3*d^2+K4*e^2)*x6-2*(K3*c*d+K4*e^2)*x3
U can see that all Mass Coefficients are with second order derivates only, Damping(C) terms with single order derivates and Stiffness(K) terms with zero order derivates. In state space Matrix form, it can be seen as [M][Ẍ]+[C][ẋ]+[K][x] = F.
Now, I need to convert these ODEs to State space form i.e. extract the M, C & K coefficients and make 6X6 matrices.
Presently, I am manually collecting all the terms and create the matrices. However, I want a matlab code which can auto populate the matrices.
Please create a code. Thank you. second order ode, state space form MATLAB Answers — New Questions