Plot step response for control signal (u1 u2 ...) in a MIMO system with feedback
Show older comments
0) Especify aditional variables and its values (use space as separator)
otherVars = "K1 K2 B1 B2 m1 m2"; otherVars = split(otherVars);
valueVars = "1 1 1 1 1 1"; valueVars = split(valueVars);
if length(otherVars) == length(valueVars)
arrayfun(@eval,strcat(otherVars,'=',valueVars));
else
warning("Number of variables not equal to its values")
return
end
1) Define the state space matrices
% STATE SPACE REPRESENTATION
AA = [0 0 1 0;0 0 0 1;-K1/m1 K1/m1 -B1/m1 B1/m1;K1/m2 -(K1+K2)/m2 -B1/m2 -(B1+B2)/m2];
BB = [0 0;0 0;1/m1 0;0 1/m2];
CC = [1 0 0 0;0 1 0 0];
DD = [0 0;0 0];
1.1) Define the value of for every
T = [4 4]; I = eye(size(DD,1)); s = tf('s');
2) Obtain the plant transfer function
Gp = tf(ss(AA,BB,CC,DD))
Gp.TimeUnit = 'seconds';
Gp.InputName = 'u';
Gp.OutputName = 'y';
3) Obtain the open loop transfer function
Go = (1/s)*diag(1./T)
4) Obtain the full process transfer function
G = feedback(Go,I)
5) Obtain the PID controller block transfer function
Gc = Gp\Go; Gc = minreal(Gc)
Gc.TimeUnit = 'seconds';
Gc.InputName = 'e';
Gc.OutputName = 'u';
6) Plot the step response from input r to output y
timeLimit = 40;
Sum1 = sumblk('e=r-y',size(T,2));
Cnt = connect(Gc,Gp,Sum1,'r','y','u');
step(Cnt,timeLimit,'r'), grid on
7) Plot the response from input r to output u (problem here)
Tp = getIOTransfer(Cnt,'r','u');
step(Tp,timeLimit,'r'), grid on
I want to obtain the plots for U as this one, is the same problem but the data is obtained through a for loop

This is the original diagram block that I'm trying to simulate without using for loops

Accepted Answer
More Answers (1)
The original plant is a coupled 2nd-order MIMO system. If the desired closed-loop transfer function
is a 1st-order system, this suggests there is loss of information, and in your case, the velocity becomes unobservable.
By redesigning your desired
, see example below, you should be able to make
proper.
Moreover, the settling time of the closed-loop transfer function is almost the same as the time in the previous
.
otherVars = "K1 K2 B1 B2 m1 m2"; otherVars = split(otherVars);
valueVars = "1 1 1 1 1 1"; valueVars = split(valueVars);
if length(otherVars) == length(valueVars)
arrayfun(@eval,strcat(otherVars,'=',valueVars));
else
warning("Number of variables not equal to its values")
return
end
AA = [0 0 1 0;0 0 0 1;-K1/m1 K1/m1 -B1/m1 B1/m1;K1/m2 -(K1+K2)/m2 -B1/m2 -(B1+B2)/m2];
BB = [0 0;0 0;1/m1 0;0 1/m2];
CC = [1 0 0 0;0 1 0 0];
DD = [0 0;0 0];
T = [4 4];
I = eye(size(DD, 1));
s = tf('s');
Gp = tf(ss(AA, BB, CC, DD))
Gp.TimeUnit = 'seconds';
Gp.InputName = 'u';
Gp.OutputName = 'y';
w = 5/13;
Go = tf(w^2, [1 2*w 0])
Gc = Gp\Go;
Gc = minreal(Gc)
Gc.TimeUnit = 'seconds';
Gc.InputName = 'e';
Gc.OutputName = 'u';
timeLimit = 40;
Sum1 = sumblk('e = r - y', size(T, 2));
Cnt = connect(Gc, Gp, Sum1, 'r', 'y', 'u');
step(Cnt, timeLimit), grid on
Tp = getIOTransfer(Cnt, 'r', 'u');
Tp = minreal(tf(Tp))
step(Tp, timeLimit, 'r'), grid on
Categories
Find more on Tuning Goals in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


