How do I make make one pode plot form a MIMO State-Space equation

I have a State-Space equation which has matrices insice the A, B and C matrices, how do I get one (combined) bode plot from the four seperate bode plots?
this is my code
%% Defining EOM matrices
M0 = [ms 0;
0 IA];
K0 = [k1+k2 k1*lA1-k2.*lA2;
k1*lA1-k2.*lA2 k1*lA1^2-k2*lA2.^2];
D0 = [-d1-d2 0;
0 0];
%% Identity and zero matrix
I = eye(2);
Zero = zeros(2,2);
%% Defining State Space equations
A = [Zero I;
-inv(M0)*K0 -inv(M0)*D0];
B = [Zero;
-inv(M0)*I];
C = [I Zero];
D = 0;
sys_mimo = ss(A,B,C,D)
bodeplot(sys_mimo)
Thanks in advance

2 Comments

What are those variables? (ms, IA, k1,k2,... etc. )
Provide all the code or variable definitions.
sorry for the inconvenience, those variables are sytem parameters, m for mass IA for moment of inertia k spring constants and d dampingsfactors below the full code:
close all; clear all; clc
%% defining variables
ms = 9;
k1 = 3e6;
k2 = 3e6;
Beta = 0.001;
d1 = Beta*(2*sqrt(ms*k1));
d2 = Beta*(2*sqrt(ms*k1));
L = 1.02;
l1 = 0.6;
l2 = 0.15;% 0.25;
lA1 = l1-(L/2) ;
lA2 = (L/2)-l2;
b = sqrt(2*0.08^2);
IA = (1/12)*ms*(b^2+(L/2)^2);
%% Defining EOM matrices
M0 = [ms 0;
0 IA];
K0 = [k1+k2 k1*lA1-k2.*lA2;
k1*lA1-k2.*lA2 k1*lA1^2-k2*lA2.^2];
D0 = [-d1-d2 0;
0 0];
%% Identity and zero matrix
I = eye(2);
Zero = zeros(2,2);
%% Defining State Space equations
A = [Zero I;
-inv(M0)*K0 -inv(M0)*D0];
B = [Zero;
-inv(M0)*I];
C = [I Zero];
D = 0;
sys_mimo = ss(A,B,C,D)
figure(1)
bodeplot(sys_mimo)

Sign in to comment.

 Accepted Answer

I doubt that combining them makes any sense from a control system perspective.
Experiment with this approach:
rng(0,'twister'); % For reproducibility
H = rss(4,2,3);
[mag,phase,wout] = bode(H);
mag_avg = squeeze(mean(mag,[1 2])); % Combined Dimensions Introduced in R2018b
phs_avg = squeeze(mean(phase,[1 2]));
figure
bodeplot(H)
figure
subplot(2,1,1)
plot(wout, 20*log10(mag_avg))
ylabel('Combined Magnitude (dB)')
subplot(2,1,2)
plot(wout, phs_avg)
xlabel('Frequency (r/s)')
ylabel('Combined Phase (\circ)')
Use whatever method you want to combine them. If you have R2018a or earlier, you will have to do the operations once for rows (dimension 1) and once for columns (dimension 2).

4 Comments

I have a earlier matlab version, but I don't understand how I would be supposed to do these operations could you elaborate further on that please?
To do the averages (or whatever operations you want to do), you would simply have to compute them in steps, for example:
mag_avg = squeeze(mean(mag));
mag_avg = squeeze(mean(mag_avg,2));
That should work.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!