Operators and Keywords

Function List:


: ones (n)
: ones (m, n)
: ones (m, n, k, …)
: ones ([m n …])
: ones (…, class)

Return a matrix or N-dimensional array whose elements are all 1.

If invoked with a single scalar integer argument n, return a square NxN matrix.

If invoked with two or more scalar integer arguments, or a vector of integer values, return an array with the given dimensions.

To create a constant matrix whose values are all the same use an expression such as

val_matrix = val * ones (m, n)

The optional argument class specifies the class of the return array and defaults to double. For example:

val = ones (m,n, "uint8")

See also: zeros.

Package: octave