www.gusucode.com > robust 案例源码程序 matlab代码 > robust/ReplaceUncertainParameterswithValuesReturnedbyusampleExample.m
%% Replace Uncertain Parameters with Values Returned by usample % Replace the uncertain parameters in an uncertain models by values specified % in struct array form, as returned by |usample|. % % This is useful, for example, when you have multiple uncertain models that % use the same set of parameters, and you want to evaluate all models at % the same parameter values. % Copyright 2015 The MathWorks, Inc. %% % Create two uncertain matrices that have the same uncertain parameters, % |a| and |b|. a = ureal('a',5); b = ureal('b',-3); M1 = [a b]; M2 = [a b;0 a*b]; %% % Generate some random samples of |M1|. [M1rand,samples] = usample(M1,5); %% % |M1rand| is an array of five values of |M1|, evaluated at randomly generated % values of |a| and |b|. These |a| and |b| values are returned in the struct % array |samples|. %% % Examine the struct array |samples|. samples %% % The field names of |samples| correspond to the uncertain parameters of % |M1|. The values are the parameter values used to generate |M1rand|. Because % |M2| has the same parameters, you can use this structure to evaluate |M2| % at the same set of values. %% M2rand = usubs(M2,samples); %% % This command returns a 1-by-5 array of instantiations of |M2|.