MATLAB ones/zeros functions

Description

Create a matrix consisting of all ones or zeros.

Usage

1
2

Arguments

...

numeric dimensions for the result

Value

Returns matrix consisting only of ones (or zeros). Defaults to square if dimension argument resolves to a single value.

Author(s)

P. Roebuck proebuck@mdanderson.org

See Also

eye

Examples

1
2
3
4
5
ones(3)
ones(c(3, 3))                   # same thing 
ones(3, 3)                      # same thing
ones(size(matrix(NA, 3, 3)))    # same thing
zeros(3)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.