PID controller - How can I get specific data about the output I receive

4 次查看(过去 30 天)
Hello all,
Im new to Simulink and Matlab, and im tring to improve my skilles with Controler planning using Simulink. Im working on a DC motor PID control.
For instent, Im tring to play with the PID set up and get: Rise time, O.S, Settling time and etc.
I was thinking about adding a 'Matlab function' block and there write the code giving me the proper data im looking for:
When I open the block I see the following:
  • How do I write the code so I would run a loop examning all the input signal. I tried to run a for loop u= 0:0.0001:5 and ask if it pass the yss value and then raise a flag. Unfortently, I didnt managed to comare the complex value of the signal to yss.
  • I will be glad to here tips what is the most efftion way to run it.
Thanks very much.

回答(1 个)

Divyajyoti Nayak
Divyajyoti Nayak 2025-1-28
I see that you want to iterate over the output values of your simulation to get Rise time, Settling time, etc of the PID controller. An easy way to do this would be to export the output signal to your workspace as an array and work with that in a MATLAB script. To do so:
  1. Add an output port to your model and attach it to your output signal.
  2. Open the ‘Configuration Parameters’ dialog box either by using the shortcut ‘Ctrl + E’ or by going to ‘Modelling’ tab -> ‘Model Settings’.
  3. Go to the ‘Data Import/Export’ section and make sure ‘Output’ is checked. If the time stamps are also needed, ‘Time’ needs to be checked.
  4. Change the format of the output data to ‘Array’ on the right side.
  5. Click ‘Apply’ or ‘OK’ to save changes.
On running the simulation, the MATLAB workspace will contain a variable with the output data on which iteration can be done.

类别

Help CenterFile Exchange 中查找有关 Simulink Control Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by