www.gusucode.com > robust 案例源码程序 matlab代码 > robust/InstantiateUncertainParameterbyBatchSubstitutionofParameExample.m

    %% Instantiate Uncertain Parameter by Batch Substitution of Parameter for Array of Values  
% Evaluate an array of uncertain models, substituting an array of values
% for an uncertain parameter.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Create a 1-by-2 uncertain matrix with two uncertain parameters. 
a = ureal('a',5);
b = ureal('b',-3);
M = [a b];  

%% 
% Replace |a| by each of the values 1, 2, 3, and 4. 
Ma = usubs(M,'a',[1;2;3;4]); 

%%
% This command returns a 4-by-1 array of 1-by-2 uncertain matrices that
% contain one uncertain parameter |b|.  

%% 
% For each model in the array |Ma|, evaluate |b| at 10, 20, and 30. 
B = usubs(Ma,'b',[10;20;30],'-batch'); 

%%
% The |'-batch'| flag causes |usubs| to evaluate each model in the array
% at all three values of |b|. Thus |B| is a 4-by-3 array of |M| values. 

%%
% The |'-batch'| syntax here yields the same result as the parameter grid
% approach used in the previous example: 
% 
aval = [1;2;3;4];
bval = [10;20;30];
[as,bs] = ndgrid(aval,bval);
B = usubs(M,'a',as,'b',bs);