Learn R Programming

matlab (version 1.0.4.1)

ones: MATLAB ones/zeros functions

Description

Create a matrix consisting of all ones or zeros.

Usage

ones(...)
zeros(...)

Value

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

Arguments

...

numeric dimensions for the result

Author

P. Roebuck proebuck1701@gmail.com

See Also

eye

Examples

Run this code
ones(3)
ones(c(3, 3))                   # same thing 
ones(3, 3)                      # same thing
ones(size(matrix(NA, 3, 3)))    # same thing
zeros(3)

Run the code above in your browser using DataLab