Generate random samples of uncertain or generalized model
B = usample(A); B = usample(A,N) [B,SampleValues] = usample(A,N) [B,SampleValues] = usample(A,Names,N) [B,SampleValues] = usample(A,Names1,N1,Names2,N2,...) [B,SampleValues] = usample(A,N,Wmax) [B,SampleValues] = usample(A,Names,N,Wmax)
B = usample(A) substitutes
a random sample of the uncertain objects in
returning a certain (i.e., not uncertain) array of size
A can be any uncertain element, matrix,
or system, such as
also be any generalized matrix or system, such as
that contains uncertain blocks and other types of Control
Design Blocks. If
A contains non-uncertain
control design blocks, these are unchanged in
Thus, for example,
usample applied to a
both tunable and uncertain blocks, the result is a
with only tunable blocks.
B = usample(A,N) substitutes
samples of the uncertain objects in
a certain (i.e., not uncertain) array of size
[B,SampleValues] = usample(A,N)
additionally returns the specific sampled values (as a
field names are the names of
A's uncertain elements)
of the uncertain elements. Hence,
B is the same
[B,SampleValues] = usample(A,Names,N)
samples only the uncertain elements listed in the
(cell, or char array). If
Names does not include
all the uncertain objects in
be an uncertain object. Any entries of
are not elements of
A are simply ignored. Note
the same as
[B,SampleValues] = usample(A,Names1,N1,Names2,N2,...)
N1 samples of the uncertain elements listed
N2 samples of
the uncertain elements listed in
Names2, and so
size(B) will equal
[size(A) N1 N2
The scalar parameter
[B,SampleValues] = usample(A,N,Wmax) [B,SampleValues] = usample(A,Names,N,Wmax) [B,SampleValues] = usample(A,Names,N,Wmax)
umargin elements within
A are sampled, restricting the poles of the samples. If
is a continuous-time
ufrd, then the poles of sampled
umargin elements in
SampleValues will each have magnitude <=
A is a discrete-time, then sampled
umargin elements are obtained by Tustin
BW/(2*TS) as the (continuous) pole magnitude bound. In
BW should be
< 1. If the
ultidyn type is
PositiveReal, then the samples are
obtained by bilinearly transforming (see Normalizing Functions for Uncertain Elements) the
GainBounded elements described above.
Sample Real Parameter
Create a real uncertain parameter, sample it, and plot a histogram of the sampled values.
A = ureal('A',5); Asample = usample(A,500);
Examine the size of the parameter and the sample array.
Uncertain real scalar.
ans = 1×3 1 1 500
A is a scalar parameter. The dimensions of
Asample reflect that
A is a 1-by-1 parameter. Examine the data type of
ans = 'double'
The samples of the scalar parameter are numerical values.
Plot the histogram of sampled values.
Sample Responses of Uncertain Control System Model
This example illustrates how to sample the open and closed-loop response of an uncertain plant model for Monte Carlo analysis.
Create two uncertain real parameters and an uncertain plant.
gamma = ureal('gamma',4); tau = ureal('tau',.5,'Percentage',30); P = tf(gamma,[tau 1]);
Create an integral controller based on the nominal values of plant uncertainties.
KI = 1/(2*tau.Nominal*gamma.Nominal); C = tf(KI,[1 0]);
Now create an uncertain closed-loop system.
CLP = feedback(P*C,1);
Sample the plant at 20 values, distributed uniformly about the
gamma parameter cube.
[Psample1D,Values1D] = usample(P,20); size(Psample1D)
20x1 array of state-space models. Each model has 1 outputs, 1 inputs, and 1 states.
This sampling returns an array of 20 state-space models, each representing the closed-loop system within the uncertainty.
Now sample the plant at 10 values of
tau and 15 values of
[Psample2D,Values2D] = usample(P,'tau',10,'gamma',15); size(Psample2D)
10x15 array of state-space models. Each model has 1 outputs, 1 inputs, and 1 states.
Plot the step responses of the 1-D sampled plant.
Evaluate the uncertain closed-loop model at the same values using
usubs, and plot the step response.
Restrict Pole Locations in Sampled Uncertain Dynamics
To see the effect of limiting the bandwidth of sampled models with
Wmax, create two
A = ultidyn('A',[1 1]); B = ultidyn('B',[1 1]);
Sample 10 instances of each, using a bandwidth limit of 1 rad/sec on
A, and 20 rad/sec on
Npts = 10; As = usample(A,Npts,1); Bs = usample(B,Npts,20);
Plot 10-second step responses, for the two sample sets.
The lower bandwidth limit on the samples of
A results in generally slower step responses for those samples.
ureal elements is uniform in actual values
Behavior changed in R2020a
Beginning in R2020a,
usample uniformly samples the actual uncertainty
ureal objects. Previously,
usample first normalized the uncertain element, and then sampled uniformly
in the normalized range. As a result of this change, you might obtain different results when you
usample to sample
ureal elements or
uss models that contain them, even if you use the same random seed.
The new implementation yields more uniform sampling for
with skewed ranges (nominal value closer to one end of the range than the other). However,
highly skewed ranges can lead to poor numeric conditioning and poor results. Therefore, for
meaningful results, avoid highly skewed ranges where the nominal value is orders of magnitude
closer to one end of the range than to the other.