sample is used to draw samples on a parameter in an optimizer object and then concatenate all sampled models.

```
Model = sample(UncertainModel) % Draw 1 sample
Model = sample(UncertainModel) % Draw N samples and concatenate all models
```

The following model represents a linear model (in **x**) with a normally distributed uncertainty

```
A = [ones(1,2);eye(2);-eye(2)];
b = ones(5,1);
E = [1 2;3 4;5 6;7 8;9 10];
x = sdpvar(2,1); % Our decision variable
w = sdpvar(2,1); % Uncertainty
Constraints = [(A + sum(w))*x <= b + E*w, uncertain(w,'normal',[0;0],[.01;.02])];
Objective = sum(x);
S = optimizer(Constraints, Objective,[],w,x)
```

The feasible set without uncertainty is given by

```
plot(S([0;0]))
```

By using sample, we can draw a number of samples on the uncertain variable, and concatenate all the generated constraints.

```
S_10_scenarios = sample(S,10);
plot(S_10_scenarios)
x_optimal = S_10_scenarios([]);
```

If the objective also is uncertain, the sample average is returned

```
Objective = (x - sum(w))'*(x - sum(w)) + sum(x);
S = optimizer(Constraints, Objective,[],w,x);
S_10_scenarios = sample(S,10);
x_optimal = S_10_scenarios([])
```