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

    %% Create and Configure slTuner Interface for Control System Tuning  
% Create and configure an |slTuner| interface for a Simulink(R) model that 
% specifies which blocks to tune with |systune| or |looptune|.   

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

%% 
% The control system consists of two feedback loops, an inner loop with
% PI controller |C2|, and an outer loop with PI controller |C1|. Suppose
% you want to tune this model to meet the following control objectives: 
%  
% * Track setpoint changes to |r| at the system output |y1m| with zero steady-state
% error and specified rise time.  
% * Reject the disturbance represented by |d2|.   
%
% The |systune| command can jointly tune the controller blocks to meet these
% design requirements, which you specify using |TuningGoal| objects. The
% |slTuner| interface sets up this tuning task.  

%% 
% Create an |slTuner| interface for the model. 
st = slTuner(mdl,{'C1','C2'}); 

%%
% This command initializes the |slTuner| interface and designates the two
% PI controller blocks as tunable. Each tunable block is automatically parameterized
% according to its type and initialized with its value in the Simulink model.
% A linearization of the remaining, nontunable portion of the model is computed
% and stored in the |slTuner| interface.  

%% 
% To configure the |slTuner| interface, designate as analysis points any
% signal locations of relevance to your design requirements. Add the output
% and reference input for the tracking requirement. Also, add the disturbance-rejection
% location. 
addPoint(st,{'r','y1m','d2'}); 

%%
% These locations in your model are now available for referencing in |TuningGoal|
% objects that capture your design goals.  

%% 
% Display a summary of the |slTuner| interface configuration in the command
% window. 
st 

%%
% The display lists the designated tunable blocks, analysis points, and
% other information about the interface. In the command window, click on
% any highlighted signal to see its location in the Simulink model. Note
% that specifying the block name |'d2'| in the |addPoint| command is equivalent
% to designating that block’s single output signal as the analysis point.  

%% 
% You can now capture your design goals with |TuningGoal| objects and use
% |systune| or |looptune| to tune the control system to meet those design
% goals.  

%% 
% In addition to specifying design goals, you can use analysis points for
% extracting system responses. For example, extract and plot the step response
% between the reference signal |'r'| and the output |'y1m'|. 
T = getIOTransfer(st,'r','y1m');
stepplot(T)