When an uncertain model has multiple uncertain elements, you can sample a subset of them, allowing other elements to remain uncertain. You can also generate sample grids by sampling multiple elements independently. For instance, consider a mass-spring-damper system with uncertain mass m, damping constant c, and spring constant k. The system has the following transfer function:
.
Create an uncertain state-space model representing the mass-spring-damper system, using ureal
parameters for the three uncertain coefficients.
Uncertain continuous-time state-space model with 1 outputs, 1 inputs, 2 states.
The model uncertainty consists of the following blocks:
c: Uncertain real, nominal = 1, variability = [-20,20]%, 1 occurrences
k: Uncertain real, nominal = 2, variability = [-30,30]%, 1 occurrences
m: Uncertain real, nominal = 3, variability = [-40,40]%, 1 occurrences
Type "A.NominalValue" to see the nominal value and "A.Uncertainty" to interact with the uncertain elements.
First, sample the model at five values of the mass m
.
5x1 array of uncertain continuous-time state-space models.
Each model has 1 outputs, 1 inputs, 2 states, and the following uncertain blocks:
c: Uncertain real, nominal = 1, variability = [-20,20]%, 1 occurrences
k: Uncertain real, nominal = 2, variability = [-30,30]%, 1 occurrences
Type "B1.NominalValue" to see the nominal value and "B1.Uncertainty" to interact with the uncertain elements.
B1
is an array of five models, sampled at each of five values of m
. The models in B1
no longer contain the uncertain element m
, which has been sampled away. However, because you have not sampled c
and k
, the models in B1
still contain those uncertain parameters. The randomly generated values of m
are returned in SampleValues1
, which is an array of five structures with a single field, m. All values fall within the specified uncertainty range of m
.
SampleValues1=5×1 struct array with fields:
m
Next, sample at five values of m
and c
, or five randomly chosen (m,c)
pairs. To do so, specify both elements in the same Names
argument. This time, k
is the only remaining uncertain parameter in the resulting models.
5x1 array of uncertain continuous-time state-space models.
Each model has 1 outputs, 1 inputs, 2 states, and the following uncertain blocks:
k: Uncertain real, nominal = 2, variability = [-30,30]%, 1 occurrences
Type "B2.NominalValue" to see the nominal value and "B2.Uncertainty" to interact with the uncertain elements.
B2
is also an array of five models, one at each of the randomly chosen (m,c)
pairs. The structure array SampleValues2
also contains five entries, the corresponding values of m
and c
.
SampleValues2=5×1 struct array with fields:
c
m
Now, instead of sampling (m,c)
pairs, let m
and c
vary independently. Sample at five values of m
and three values of c
.
5x3 array of uncertain continuous-time state-space models.
Each model has 1 outputs, 1 inputs, 2 states, and the following uncertain blocks:
k: Uncertain real, nominal = 2, variability = [-30,30]%, 1 occurrences
Type "B3.NominalValue" to see the nominal value and "B3.Uncertainty" to interact with the uncertain elements.
This time, usample
creates a grid of values (mi,cj)
, the five random m
values paired with each of the three random c
values. Therefore, B3
is a 5-by-3 array of models. Each entry SampleValues3(i,j)
in the structure array contains the corresponding values (mi,cj)
.
SampleValues3=5×3 struct array with fields:
c
m
Examine the sample values to see the independent variation of m
and c
. For instance, SampleValues3(1,1)
and SampleValues3(1,3)
have the same m
but different c
, while SampleValues3(1,3)
and SampleValues3(2,3)
have the same c
but different m
.
ans = struct with fields:
c: 1.0623
m: 2.1405
ans = struct with fields:
c: 1.1397
m: 2.1405
ans = struct with fields:
c: 1.1397
m: 2.8122
Finally, if you sample all three uncertain parameters, the result is an array of numeric (non-uncertain) state-space models. For instance, sample at a three-dimensional grid of five m
values, three c
values, and two k
values.
5x3x2 array of state-space models.
Each model has 1 outputs, 1 inputs, and 2 states.