www.gusucode.com > slcontrol 案例源码程序 matlab代码 > slcontrol/CreateandConfigureslLinearizerInterfaceforBatchLinearAnaExample.m

    %% Create and Configure slLinearizer Interface for Batch Linear Analysis  
% Create an |slLinearizer| interface for the |scdcascade| model. Add analysis
% points to the interface to extract open- or closed-loop transfer functions
% from the model. Configure the interface to vary parameters and operating
% points.   

%% 
% Open the |scdcascade| model. 
mdl = 'scdcascade';
open_system(mdl);    

%% 
% Create an |slLinearizer| interface for the model. Add the signals |r|,
% |u1|,|u2|, |y1|,|y2|, |y1m|, and |y2m| to the interface. 
sllin = slLinearizer(mdl,{'r','u1','u2','y1','y2','y1m','y2m'});  

%% 
% |scdcascade| contains two PID Controller blocks, |C1| and |C2|. Suppose
% you want to vary the proportional and integral gains of |C2|, |Kp2| and
% |Ki2|, in the 10% range. Create a structure to specify the parameter variations. 
Kp2_range = linspace(0.9*Kp2,1.1*Kp2,3);
Ki2_range = linspace(0.9*Ki2,1.1*Ki2,5);

[Kp2_grid,Ki2_grid]=ndgrid(Kp2_range,Ki2_range);

params(1).Name = 'Kp2';
params(1).Value = Kp2_grid;

params(2).Name = 'Ki2';
params(2).Value = Ki2_grid; 

%%
% |params| specifies a 3x5 parameter grid. Each point in this grid corresponds
% to a combination of the |Kp2| and |Ki2| parameter values.  

%% 
% Specify |params| as the |Parameters| property of |sllin|. 
sllin.Parameters = params; 

%%
% Now, when you use commands such as |getIOTransfer|, |getLoopTransfer|,
% |getSensitivity|, and |getCompSensitivity|, the software returns a linearization
% for each parameter grid point specified by |sllin.Parameters|.  

%% 
% Suppose you want to linearize the model at multiple snapshot times, for
% example at |t = {0,1,2}|. To do so, configure the |OperatingPoints| property
% of |sllin|. 
sllin.OperatingPoints = [0 1 2];  

%% 
% You can optionally configure the linearization options and specify substitute
% linearizations for blocks and subsystems in your model. After fully configuring
% |sllin|, use the |getIOTransfer|, |getLoopTransfer|, |getSensitivity|,
% and |getCompSensitivity| commands to linearize the model as required.