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

30 次查看(过去 30 天)
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 ?

回答(1 个)

Sam Chak
Sam Chak 2022-11-1
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 个评论
aiman
aiman 2022-11-1
@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 2022-11-1
编辑:Sam Chak 2022-11-1
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by