How to simulate a transfer function matrix of closed loop MIMO system?

23 views (last 30 days)
Hi,
I have bi MIMO system with 7 inputs and 5 states and 5 outputs. I have simulate the open loop system using 'lsim' which shows the system is unstable. I designed a decentralized controller and now I want to show that my closed loop system is stable by simulating the transfer function matrix. However, now when I simulate the transfer function matrix using 'lsim' all the outputs are NAN. How can I simulate closed loop transfer function of MIMO system using matlab?
Thanks, Hamid
  2 Comments
Hamidreza Jafarian
Hamidreza Jafarian on 7 Apr 2016
Thank you Ced for your response. How can I make sure "all the connections are fed back correctly?"? This section of my code is as below:
controller=[comp11*cos(alpha_angle1) 0 0 0 0; comp11*sin(alpha_angle1) 0 0 0 0; 0 comp21*cos(alpha_angle2) 0 0 0; 0 comp21*sin(alpha_angle2) 0 0 0; 0 0 comp31*comp32 comp32 0; 0 0 0 0 comp32 0 0 0 0 0];
feedback_matrix = [1 0 0 0 0; 0 1 0 0 0; 0 0 1 0 0; 0 0 0 1 0; 0 0 0 0 1]; sys_closed_loop = feedback(controller'*sys_orig_tf',feedback_matrix);
"sys_orig_tf'" is my open loop transfer function with 7 inputs and 5 outputs.
Thanks, Hamid

Sign in to comment.

Accepted Answer

Ced
Ced on 7 Apr 2016
Edited: Ced on 7 Apr 2016
Careful!!
sys_orig_tf' not only transposes your system, but takes the complex conjugate of it! This most likely completely changes your system. You probably don't want this. (Happened to me before too ...)
For the actual question, you can name your signals, that way matlab will issue a warning when there are missing connections or so. feedback has an option to use IO names, or alternatively you can use the connect function to specify which are the inputs and output of your systems. Connections with the same name are automatically matched. I think the help has some nice examples, let me know if you have questions.
One more thing:
You can define a feedthrough system (which your controller basically is) in a clean way using ss. E.g. if you have 3 inputs u, and want u1 = 1*pos, u2 = 2*vel, u3 = 5*acc, where pos, vel, acc are the three states/outputs you are feeding back (hypothetically) as compensation, you could
controller = ss([],[],[],diag([ 1 2 5 ]));
controller.InputName = {'pos','vel','acc'};
controller.OutputName = {'u1','u2','u3'};
Note that the output of your plant are the input of the controller ( and vice-versa ).
  3 Comments
Ced
Ced on 8 Apr 2016
Edited: Ced on 8 Apr 2016
Hi
You can transpose it, just not with ', which in matlab is the hermitian operator (i.e. complex conjugate transpose). You need to use either .' (with the dot) or transpose.
Example:
% System with 1 input, 2 outputs
% Each tf is 1/(s^2 + s + 1)
P = tf({1 ; 1},{[1 1 1];[1 1 1]});
% Hermitian system: 2 inputs, 1 output
% Each tf is 1/(s^2 - s + 1), NOTE the minus!
P'
% Transposed system: 2 inputs, 1 output
% Each tf is 1/(s^2 + s + 1)
P.'
transpose(P)
I'm not sure I understand why exactly you need to transpose your system though. Generally, it would be P*C.
Then, for the second issue: You need to specify the I/O names as cells of strings, otherwise Matlab cannot know which ones are supposed to be inputs and which ones outputs, i.e.
cl_u = {'r1','r2','r3','r4'};
cl_y = {'Vg','Vdc1','Vdc2','Vdc3','Id','Iq'};
sys_closed_loop = connect(sys_orig_tf,D1,D2,PI1,PI2,PI3,PI4,PI5,Sum1,Sum2,Sum3,Sum4,Sum5, cl_u, cl_y);

Sign in to comment.

More Answers (1)

Harish Kumar Anandan
Harish Kumar Anandan on 27 Mar 2018
I have a 2 input 2 output system and I have designed H-infinity controller for the system, Now when I try to get step response how to give feedback command? sO FAR I HAVE WORKED WITH
% step response plant1stp=sbs (g11,g12); plant2stp=sbs (g21,g22); overalplant=abv(plant1stp,plant2stp); loop1=mmult(overalplant,hinf_cont); [l,m,n,o]=unpck(loop1);
disp('step responses') clf step(l1,m1,n1,o1,2)

Community Treasure Hunt

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

Start Hunting!