# usample

Generate random samples of uncertain or generalized model

## Syntax

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)

## Description

`B = usample(A)`

substitutes
a random sample of the uncertain objects in `A`

,
returning a certain (i.e., not uncertain) array of size` [size(A)]`

.
The input `A`

can be any uncertain element, matrix,
or system, such as `ureal`

, `umat`

, `uss`

,
or `ufrd`

. `A`

can
also be any generalized matrix or system, such as `genss`

or `genmat`

,
that contains uncertain blocks and other types of Control
Design Blocks. If `A`

contains non-uncertain
control design blocks, these are unchanged in `B`

.
Thus, for example, `usample`

applied to a `genss`

with
both tunable and uncertain blocks, the result is a `genss`

array
with only tunable blocks.

`B = usample(A,N)`

substitutes `N`

random
samples of the uncertain objects in `A`

, returning
a certain (i.e., not uncertain) array of size` [size(A) N]`

.

`[B,SampleValues] = usample(A,N)`

additionally returns the specific sampled values (as a `Struct`

whose
field names are the names of `A'`

s uncertain elements)
of the uncertain elements. Hence, `B`

is the same
as `usubs(A,SampleValues)`

.

`[B,SampleValues] = usample(A,Names,N)`

samples only the uncertain elements listed in the `Names`

variable
(cell, or char array). If `Names`

does not include
all the uncertain objects in `A`

, then `B`

will
be an uncertain object. Any entries of `Names`

that
are not elements of` A`

are simply ignored. Note
that `usample(A,fieldnames(A.Uncertainty),N)`

is
the same as `usample(A,N)`

.

`[B,SampleValues] = usample(A,Names1,N1,Names2,N2,...)`

takes `N1`

samples of the uncertain elements listed
in `Names1`

, and `N2`

samples of
the uncertain elements listed in `Names2`

, and so
on. `size(B)`

will equal ```
[size(A) N1 N2
...]
```

.

The scalar parameter `Wmax`

in

[B,SampleValues] = usample(A,N,Wmax) [B,SampleValues] = usample(A,Names,N,Wmax) [B,SampleValues] = usample(A,Names,N,Wmax)

affects how `ultidyn`

and `umargin`

elements within
`A`

are sampled, restricting the poles of the samples. If `A`

is a continuous-time `uss`

or `ufrd`

, then the poles of sampled
`GainBounded`

`ultidyn`

or `umargin`

elements in
`SampleValues`

will each have magnitude <= `BW`

. If
`A`

is a discrete-time, then sampled `GainBounded`

`ultidyn`

or `umargin`

elements are obtained by Tustin
transformation, using `BW/(2*TS)`

as the (continuous) pole magnitude bound. In
this case, `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.

## Examples

## Compatibility Considerations

## See Also

`usample`

| `rsampleBlock`

| `usubs`

| `ufind`

| `ureal`

| `ucomplex`

| `ultidyn`

| `umat`

| `ufrd`

| `uss`

| `umargin`

**Introduced in R2009b**