MATLAB Function Reference
  Go to function:
    Search    Help Desk 
ones    See Also

Create an array of all ones

Syntax

Description

Y = ones(n) returns an n-by-n matrix of 1s. An error message appears if n is not a scalar.

Y = ones(m,n) or Y = ones([m n]) returns an m-by-n matrix of ones.

Y = ones(d1,d2,d3...) or Y = ones([d1 d2 d3...]) returns an array of 1s with dimensions d1-by-d2-by-d3-by-....

Y = ones(size(A)) returns an array of 1s that is the same size as A.

See Also

eye         Identity matrix

rand        Uniformly distributed random numbers and arrays

randn       Normally distributed random numbers and arrays

zeros       Create an array of all zeros



[ Previous | Help Desk | Next ]