| MATLAB Function Reference | Search  Help Desk |
| ones | See Also |
Syntax
Y=ones(n) Y=ones(m,n) Y = ones([m n]) Y =ones(d1,d2,d3...) Y = ones([d1 d2 d3...]) Y =ones(size(A))
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, rand, randn, zeros