### Standard arrays

Sometimes, it is useful to be able to generate image arrays with known characteristics to tryout ideas and to test the syntax of functions during development.

Some of the standard arrays are :-

• zeros (M, N) generates an M x N matrix of Os of class double.
• ones (M, N) generates an M x N matrix of Is of class double.
• true (M, N) generates an M x N logi cal matrix of Is.
• false (M, N) generates an M x N logical matrix of Os.
• magic (M) generates an M x M “magic square.” This is a square array in which the sum along any row, column, or main diagonal, is the same. Magic squares are useful arrays for testing purposes because they are easy to generate and their numbers are integers.
• eye (M) generates an M x M identity matrix.
• rand (M, N) generates an M x N matrix whose entries are uniformly distributed random numbers in the interval [0 , 1].
• randn (M, N) generates an M x N matrix whose numbers are normally distributed (i.e., Gaussian) random numbers with mean 0 and variance 1.

#### Example

```>> A = ones(3,3)

A =

1     1     1
1     1     1
1     1     1

>> A = 2*ones(3,3)

A =

2     2     2
2     2     2
2     2     2
```

#### Random matrices

```>> magic(4)

ans =

16     2     3    13
5    11    10     8
9     7     6    12
4    14    15     1
```