This example shows how to use Simulink Control Design from the command line by linearizing a watertank Simulink Model feedback control system. An open-loop linearized model of the watertank will be extracted at an operating point where the tank level is at H = 10. The following 3 steps linearize and analyze the water-tank model.
For more information on programmatically specifying:
Input and output points for linearizing a model, see Specify Portion of Model to Linearize and Specify Portion of Model to Linearize at Command Line.
Finding operating points for a linearization, see Compute Steady-State Operating Points from Specifications and Compute Operating Points from Specifications at the Command Line.
Open the model.
watertank
The linearization points specify the inputs and outputs of a linearized model. To extract the open loop linearized model, add an input point at the output of the Controller block and an output point, with a loop opening, at the output of the Water-Tank System block.
Specify the input point.
watertank_io(1)=linio('watertank/PID Controller',1,'input');
Specify the output point with a loop opening.
watertank_io(2)=linio('watertank/Water-Tank System',1,'openoutput');
The linearization points can then be set and viewed in the model.
setlinio('watertank',watertank_io);
watertank
This next step involves finding an operating point of the Simulink model 'watertank' so that the level of the tank is at H = 10. One approach is to simulate the model then extract the operating point when the simulation is near the desired value. The command FINDOP will simulate a model and extract the operating points at times defined in the function call.
opsim = findop('watertank',10)
Operating point for the Model watertank. (Time-Varying Components Evaluated at time t=10) States: ---------- (1.) watertank/PID Controller/Integrator/Continuous/Integrator x: 1.69 (2.) watertank/Water-Tank System/H x: 10.1 Inputs: None ----------
In this operating point, H is not at the desired value of 10. However, you can use this operating point to initialize a search for the desired operating point where H = 10. An operating point specification object allows you to specify the desired value of H = 10.
Create an operating point specification object.
opspec = operspec('watertank');
Initialize the values of the states of the operating point specification with the ones in the operating point opsim.
opspec = initopspec(opspec,opsim);
The specified operating point can then be searched for (trimmed) using the FINDOP command.
opss = findop('watertank',opspec);
Operating point search report: --------------------------------- Operating point search report for the Model watertank. (Time-Varying Components Evaluated at time t=10) Operating point specifications were successfully met. States: ---------- (1.) watertank/PID Controller/Integrator/Continuous/Integrator x: 1.26 dx: 0 (0) (2.) watertank/Water-Tank System/H x: 10 dx: -1.1e-14 (0) Inputs: None ---------- Outputs: None ----------
You are now ready to linearize the plant model by using the LINEARIZE function.
sys = linearize('watertank',opss,watertank_io);
The resulting model is a state space object that you can analyze using any of the tools in the Control System Toolbox software.
bode(sys);
Close the Simulink model.
bdclose('watertank')