how to build a control system with one input and multiple outputs

39 次查看(过去 30 天)
hello~
I want to build a system like this. I don't know how to deal with the separate output from modul F

采纳的回答

Paul
Paul 2021-11-21
编辑:Paul 2021-11-21
Here is one approach (there are others), with simple examples tf's for C, F, and G, that you should be able to adapt to your problem.
The trick is to replicate F so that it has two outputs. One output to add to G and the other to keep as the output of the closed loop system.
% Example data
C = tf(1,[1 0]);
F = tf(1,[1 1]);
G = tf(1,[1 2]);
% Create a new version of F that has two outputs that are the same as each
% other. One output of F will be added to the output of G and the other
% will be retained as the output of the system
Fnew = [F;F];
% Create E
E = parallel(Fnew,G,1,1,2,1);
% E now is 1-input, 2-output. The first output is F, and the other is the
% sum of E and F. Check
E
E = From input to output... 1 1: ----- s + 1 2 s + 3 2: ------------- s^2 + 3 s + 2 Continuous-time transfer function.
F
F = 1 ----- s + 1 Continuous-time transfer function.
minreal(G+F)
ans = 2 s + 3 ------------- s^2 + 3 s + 2 Continuous-time transfer function.
% Now put C in series with E
H = series(C,E)
H = From input to output... 1 1: ------- s^2 + s 2 s + 3 2: ----------------- s^3 + 3 s^2 + 2 s Continuous-time transfer function.
% Now close the loop using the second output of H
ClosedLoop = feedback(H,1,1,2,-1)
ClosedLoop = From input to output... s^3 + 3 s^2 + 2 s + 1.089e-16 1: --------------------------------- s^5 + 4 s^4 + 7 s^3 + 7 s^2 + 3 s 2 s + 3 2: --------------------- s^3 + 3 s^2 + 4 s + 3 Continuous-time transfer function.
% Hmm, why are the denominators different?
zpk(ClosedLoop)
ans = From input to output... s (s+2) (s+1) 1: ---------------------------------------- s (s+1.682) (s+1) (s^2 + 1.318s + 1.783) 2 (s+1.5) 2: -------------------------------- (s+1.682) (s^2 + 1.318s + 1.783) Continuous-time zero/pole/gain model.
% Looks like feedback() left some pole/zero cancellations uncancelled.
% This happened because of the lazy way I replicated F.
% It would not have happened if I would have used ss objects throughout,
% which is the preferred approach.
% But we can get rid of them.
ClosedLoop = minreal(ClosedLoop)
ClosedLoop = From input to output... s + 2 1: --------------------- s^3 + 3 s^2 + 4 s + 3 2 s + 3 2: --------------------- s^3 + 3 s^2 + 4 s + 3 Continuous-time transfer function.
% Now we can check each result individually using block diagram algebra
% (not a recommended approach in general)
minreal(F*C/(1+C*(F+G)))
ans = s + 2 --------------------- s^3 + 3 s^2 + 4 s + 3 Continuous-time transfer function.
minreal((G+F)*C/(1+C*(F+G)))
ans = 2 s + 3 --------------------- s^3 + 3 s^2 + 4 s + 3 Continuous-time transfer function.
  3 个评论
Paul
Paul 2021-11-22
Fnew as two outputs and one input, and G has one output and one input.
In this line
E = parallel(Fnew,G,1,1,2,1) % (Fnew, G, inp1, inp2, out1, out2
inp1 = inp2 = 1, which means that the new input to E is split into the first (only) input of Fnew and the first (only) input of G. out1 = 2 and out2 = 1 means that the sencond output of Fnew and the first (only) output of G are summed together to form the new output of E. The full output of E is the first output of Fnew and the new summed signal. So inp1 and inp2 are the indices of the inputs to Fnew and G respectively that are the new common input to E, and out1 and out2 are the indices of the outputs from Fnew and G that are added to form the new summed output of E. Any other inputs/outputs to/from Fnew and G are retained in E. In this case, the only other input/output retained is the first output from Fnew.
H has one input and two outputs. This command
ClosedLoop = feedback(H,1,1,2,-1) % (sys1, sys2, feedin, feedout, sign)
says to feedback the second (feedout) output of H, into the feedback block (sys2 = 1), and take the output of the feedback block with negative sign (sign = -1) to form the error signal to put into the first (feedin) input of H. Both outputs of H are retained as outputs of ClosedLoop.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2021-11-21
Create Subsystem, then click the right hand edge to Add Port for as many output ports as you need
Or, instead create your subsystem and add Outport blocks; https://www.mathworks.com/help/simulink/slref/outport.html
  1 个评论
Jun Meng
Jun Meng 2021-11-21
thanks for answering :)
but I'm not building this system in simulink, rather in MATLAB coding.
I want to know how to code this part.
here is what I already have:
E = F + G
closed_loop = (C*E, -1)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by