Learn R Programming

matlab (version 0.7-8)

ones: MATLAB ones/zeros functions

Description

Create a matrix consisting of all ones or zeros.

Usage

ones(n, m = n)
zeros(n, m = n)

Arguments

n, m
numeric scalars specifying dimensions for the result

Value

  • Returns matrix consisting only of ones (or zeros). Defaults to square if second dimension argument m not provided.

See Also

eye

Examples

Run this code
ones(3)
zeros(3)

Run the code above in your browser using DataLab