%% Control Design using Zero-Pole-Gain Models
% For this example, design a 2-DOF PID controller with a target bandwidth of 0.75 rad/s for a system represented by the following zero-pole-gain model:
% sys(s) = \frac{1}{s^2+0.5s+0.1}
% Create a zero-pole-gain model object sys using the zpk command.

zeros = [];
poles = [-0.25+0.2i;-0.25-0.2i];
gain = 1;
sys = zpk(zeros,poles,gain)

% Using the target bandwidth, use pidtune to generate a 2-DOF controller.

wc = 0.75;
C2 = pidtune(sys,'PID2',wc)

% Using the type 'PID2' causes pidtune to generate a 2-DOF controller, represented as a pid2 object. The display confirms this result. The display also shows that pidtune tunes all controller coefficients, including the setpoint weights b and c, to balance performance and robustness.
% For interactive PID tuning in the Live Editor, see the Tune PID Controller Live Editor task. This task lets you interactively design a PID controller and automatically generates MATLAB code for your live script.
% For interactive PID tuning in a standalone app, use PID Tuner. See PID Controller Design for Fast Reference Tracking for an example of designing a controller using the app.
% Copyright 2020 The MathWorks, Inc.