Main Content

Create array of all ones

`X = ones`

returns the scalar `1`

.

`X = ones(`

returns
an `sz1,...,szN`

)`sz1`

-by-...-by-`szN`

array of
ones where `sz1,...,szN`

indicates the size of each
dimension. For example, `ones(2,3)`

returns a 2-by-3
array of ones.

`X = ones(___,`

also specifies the data type (class) of `typename`

)`X`

for any of the
previous syntaxes. For example, `ones(5,'int8')`

returns a
5-by-5 matrix of 8-bit integers.