MATLAB: Implementation of a multiple PI controller in Simulink

pi controllersimulink

Hi! I am having issues on creating a multiple PI-controller for a state-space model with two state variables as shown. This was a demo code from Matlab which is very similar to what I am trying to implement. The full state-space model equation is executed below from the given variables. When I create the simulink to implement multiple PI controller to tune both the state variable (X1 and X2), Simulink always shows an error that the dimensions doesn't match. Please see the error below.
a = [-0.5572,-0.7814;0.7814,0]; b = [1,-1;0,2]; c = [1.9691,6.4493]; sys = ss(a,b,c,0); step(sys)
>> sys
sys =
A =
x1 x2
x1 -0.5572 -0.7814
x2 0.7814 0
B =
u1 u2
x1 1 -1
x2 0 2
C =
x1 x2
y1 1.969 6.449

Best Answer

You have not entered the D matrix correctly. Your output is 1x1 scalar in the way you constructed your state space model because your C matrix is 1x2, the X vector is 2x1, then the multiplication will be 1x1 scalar. D matrix has to be 1x2 vector. DON'T USE ANY DEMUX AT THE OUTPUT SINCE YOUR OUTPUT IS 1x1. I made the same model and it worked for me without errors, in this case, enter your D matrix as:
D=[0 0];