How can I obtain the State space from the Mass,stiffness,damping matrices

18 vues (au cours des 30 derniers jours)
aiman
aiman le 1 Nov 2022
Modifié(e) : Sam Chak le 1 Nov 2022
I've modeled a system using Matlab and I want to obtain the State space from Mass,stiffness,damping matrices..is there a function on matlab doing that ?
  2 commentaires
Michael
Michael le 1 Nov 2022
Can you given an example of your mass, spring, damping matricies?
aiman
aiman le 1 Nov 2022
Mass
[m1, 0 ]
[ 0, m2 ]
Stiffness
[ k2, -k2 ]
[ -k2 k2 ]
Damping
[c1, -c2]
[ -c2, c2]

Connectez-vous pour commenter.

Réponses (1)

Sam Chak
Sam Chak le 1 Nov 2022
If the matrices are known, then you can apply these formulas:
A = [zeros(n) eye(n); M\K M\C]; % to get the State matrix
B = [zeros(n); M\eye(n)]; % to get the Input matrix
Example:
tspan = [0 30];
x0 = [1 0.5 0.25 0 0 0]; % initial values
[t, x] = ode45(@odefcn, tspan, x0);
plot(t, x), grid on, xlabel({'$t$'}, 'interpreter', 'latex')
function xdot = odefcn(t, x)
xdot = zeros(6, 1);
M = diag([2 3 5]); % Mass matrix
C = diag(randi([-20, -10], 1, 3)); % Damping matrix
K = diag(randi([-10, -1], 1, 3)); % Stiffness matrix
A = [zeros(3) eye(3); M\K M\C]; % State matrix
% B = [zeros(3); M\eye(3)]; % Input matrix
xdot = A*x; % if u = 0
% xdot = A*x + B*u;
end
  2 commentaires
aiman
aiman le 1 Nov 2022
@Sam Chak Thanks alot for your comment,It helped to get A&B but I struggling to find the output C and D to be able to use sys = ss(A,B,C,D)
Sam Chak
Sam Chak le 1 Nov 2022
Modifié(e) : Sam Chak le 1 Nov 2022
What are your desired C and D? They don't come from the mass spring damper equations of motion.
If y is your defined output that can be constructed from state vector x, then you can construct the output matrix C.
If all states x are measurable individual outputs, then C is obviously an Identity matrix.
There is no indication of the direct feedforward from the input u. So, D must be an array of zeros.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by