How to get the output of a controller from MATLAB codes not simulink
Mostra commenti meno recenti
In simulink, it is easy to get the control output (or input to the actuator) by connecting a scope to the controller output. How do you get the output of the controller in MATLAB codes? I need the output to apply to another system as well as the plant infront of the controller.
Thanks.
Risposta accettata
Più risposte (2)
I suggest using interconnection functions to build a single system model that has the control input to the plant as one of the outputs from the overall system model
One approach, for example:
Define the plant
sysp = tf(1,[1 0],'InputName','u','OutputName','y');
Define the controller
sysc = tf(1,1,'InputName','e','OutputName','u');
Unitfy feedback to form the closed loop system. Specify the outputs from the closed loop system as the output and input to the plant
sysclosed = connect(sysc,sysp,sumblk('e = r - y'),'r',{'y' 'u'});
Now we can plot the step (or any other response)
step(sysclosed)
Also, sysclosed can then be connected to other systems to build a large model if desired.
1 Commento
ojonugwa adukwu
il 22 Set 2022
ojonugwa adukwu
il 16 Set 2022
0 voti
1 Commento
Sam Chak
il 16 Set 2022
You are welcome, @ojonugwa adukwu. If you find the solution in MATLAB code is helpful, please consider accepting ✔ and voting 👍 the Answer. Thanks!
I have added an explanation in the comment under my Answer. It's almost the same argument of why use
to get the system output
, but not the plant
itself.
Categorie
Scopri di più su Simulink in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




