Generate random samples of uncertain variables in a Simulink model
samples = usample(uvars,N) samples = usample(uvars) samples = usample(uvars,N,Wmax)
samples = usample(uvars,N) generates
samples of the uncertain variables in
is a structure that lists uncertain variables (
ultidyn) by name. You can automatically obtain
uvars for a Simulink model that contains Uncertain State Space blocks using
samples is an N-by-1
structure array whose field names and values are the names and sample values of the
uncertain variables. Use this syntax, together with
generate random samples for uncertain variables in Simulink models.
samples = usample(uvars) is equivalent to
samples = usample(uvars,N,Wmax) specifies constraints, as described
uss/usample, for sampling uncertain variables of type
Create a structure that contains uncertain variables
uvars = struct('a',ureal('a',5),'b',ultidyn('b',[2 3],'Bound',7))
uvars = struct with fields: a: [1x1 ureal] b: [2x3 ultidyn]
Generate a random sample of
samples = usample(uvars)
samples = struct with fields: a: 5.6294 b: [2x3 ss]
samples is also a structure, where each field contains a randomly sampled instance of the uncertain variable type in
uvars. You can use
samples to simulate an uncertain Simulink model at these values as shown in Sample Uncertain Variables in a Simulink® Model.
Generate random samples of uncertain variables in a Simulink® model.
Open the model.
The model contains three Uncertain State Space blocks named Unmodeled Plant Dynamics, Plant, and Sensor Gain. These blocks depend on three uncertain variables named
ufind to find all Uncertain State Space blocks and uncertain variables in the model.
uvars = ufind('usim_model');
usample to generate random samples of
sensor_gain. Simulate the closed-loop response for each of these random samples.
for i=1:10; uval = usample(uvars); sim('usim_model',10); end
The MultiPlot Graph block displays the simulated responses.
Robustness Analysis in Simulink