%% Feedback Loop Based on I/O Names
% mimoPlantAndController.mat contains a 2 input, 2 output transfer function plant model G and a 2 input, 2 output transfer function controller model C to be connected as follows:
%
% First, load the plant and controller models to the workspace.

load('mimoPlantAndController.mat','G','C');
size(G)
size(C)

% By default, feedback would connect the first output of G to the first input of C and the second output of G to the second input of C. In order to connect the plant and controller according to the figure, name the respective I/Os of the two systems to ensure the correct connections.

G.InputName 
G.OutputName
C.InputName
C.OutputName

% Then use the 'name' flag with the feedback command to make the connections according to the I/O names.

sys = feedback(G,C,'name');

% The resulting closed loop negative feedback transfer function sys has the feedback connections in the required order.
% Copyright 2019 The MathWorks, Inc.