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

33 views (last 30 days)
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 ?

Answers (1)

Sam Chak
Sam Chak on 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 Comments
aiman
aiman on 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 on 1 Nov 2022
Edited: Sam Chak on 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.

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!