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

    %% Graphically Analyze Results of Control System Tuning  
% Tune the Simulink(R) model, |rct_engine_speed|, to achieve a specified
% settling time. Use |loopview| to graphically analyze the tuning results.    

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

%% 
% Create an |slTuner| interface for the model and specify the PID Controller
% block to be tuned. 
st0 = slTuner(mdl,'PID Controller');  

%% 
% Specify a requirement to achieve a 2 second settling time for the |Speed|
% signal when tracking the reference signal. 
req = TuningGoal.Tracking('Ref','Speed',2);  

%% 
% Tune the PID Controller block. 
addPoint(st0,'u')

control = 'u';
measurement = 'Speed';

wc = 1;

[st1,gam,info] = looptune(st0,control,measurement,wc);  

%% 
% View the response of the model for the tuned block values. 
loopview(st1,control,measurement);     

%% 
% Compare the performance of the tuned block against the tuning goals. 
figure
loopview(st1,info);