ones

Purpose

Creates a matrix of ones.

Format

y = ones(r, c)
Parameters:
  • r (scalar) – number of rows.
  • c (scalar) – number of columns.
Returns:

y (RxC matrix) – contains ones in all elements.

Examples

x = ones(3, 2);

The code above assigns x to be equal to:

1.0000000        1.0000000
1.0000000        1.0000000
1.0000000        1.0000000

Remarks

Non-integer arguments will be truncated to an integer.

See also

Functions zeros(), eye()