Your answer is one click away!

shdotcom February 2016
### What does the third input to rand mean?

In the MATLAB if:

```
x = rand(a,b,c);
```

What does the third input to `rand`

, `c`

, mean?

`a`

: numbers of rows

`b`

: numbers of columns

`c`

: ??

Dan February 2016

In MATLAB, matrices are not limited to 2 dimensions (i.e. only rows and columns), but can have many higher dimensions.

The *third* input to the `rand`

function is just telling `rand`

the size of the *third* dimension that you want. By default it is `1`

, but in your case it will instead be `c`

.

In general, the *nth* input to `rand`

will be the size of the *nth* dimension of the matrix of random numbers it produces.

Rahul Tripathi February 2016

See the docs:

`X = rand(sz1,...,szN)`

returns an sz1-by-...-by-szN array of random numbers where sz1,...,szN indicate the size of each dimension. For example, rand(3,4) returns a 3-by-4 matrix.

Asked in February 2016

Viewed 3,664 times

Voted 10

Answered 2 times

Viewed 3,664 times

Voted 10

Answered 2 times