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

    %% Set Value of Multiple Tunable Elements within Custom Parameterization  
%% 
% Create an |slTuner| interface for the |scdcascade| model.  

% Copyright 2015 The MathWorks, Inc.

open_system('scdcascade');
st = slTuner('scdcascade',{'C1','C2'});

%%
% Set a custom parameterization for one of the tunable blocks.
C1CustParam = realp('Kp',1) + tf(1,[1 0]) * realp('Ki',1);
setBlockParam(st,'C1',C1CustParam); 

%%
% These commands set the parameterization of the |C1| controller block to
% a generalized state-space (|genss|) model containing two tunable parameters,
% |Ki| and |Kp|.

%% 
% Create a structure of tunable element values, setting |Kp| to |5| and |Ki| 
% to |10|.
S = struct('Kp',5,'Ki',10);

%%
% Set the values of the tunable elements in |st|.
setTunedValue(st,S);