Simulink Control Design™ - MathWorks

(Tuis.) #1

Trim Model Without Customizations


Create a default operating point specification for the model. The specification configures
all three tank pressures as free states that must be at steady state in the trimmed
operating point.


opspec = operspec(mdl);


Create an option set for trimming the model, suppressing the Command Window display
of the operating point search report. The specific trimming options depend on your
application. For this example, use nonlinear least squares optimization.


opt = findopOptions('OptimizerType','lsqnonlin');
opt.DisplayReport = 'off';


Trim the model, and view the trimmed tank pressures.


[op0,rpt0] = findop(mdl,opspec,opt);
op0.States


(1.) scdTanks/Inertia
x: 0
(2.) scdTanks/Tank1
x: 9
(3.) scdTanks/Tank2
x: 9.5
(4.) scdTanks/Tank3
x: 10.5


The trimmed pressures in Tank1 and Tank2 do not match. Thus, the default operating
point specification fails to find an operating point that meets the expected steady-state
requirements. If you reduce the constraint tolerance,
opt.OptimizationOptions.TolCon, you cannot achieve a feasible steady-state
solution due to the leakage between Tank2 and Tank3.


Add Custom Constraints


To specify custom constraints, define a function in the current working folder or on the
MATLAB path with input arguments:



  • x - Operating point specification states, specified as a vector.

  • u - Operating point specification inputs, specified as a vector.

  • y - Operating point specification outputs, specified as a vector.


Compute Operating Points Using Custom Constraints and Objective Functions
Free download pdf