Here's an example of how to design a PID controller in Matlab using Simulink:
main.m337 chars18 lines
This code defines a transfer function G for a simple plant, creates a PID controller with gains Kp, Ki, and Kd, and uses Simulink's feedback function to connect the plant and controller in a closed-loop system. The resulting step response of the closed-loop system is then plotted using step.
You can modify the values of Kp, Ki, and Kd to tune your controller to better meet your control specifications.
gistlibby LogSnag