| MATLAB Function Reference | ![]() |
Y = ones(n)
Y = ones(m,n)
Y =
ones([m n])
Y = ones(m,n,p,...)
Y
= ones([m n p ...])
Y = ones(size(A))
ones(m, n,...,classname)
ones([m,n,...],classname)
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(m,n,p,...) or Y = ones([m n p ...]) returns an m-by-n-by-p-by-... array of 1s.
Note The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0. |
Y = ones(size(A)) returns an array of 1s that is the same size as A.
ones(m, n,...,classname) or ones([m,n,...],classname) is an m-by-n-by-... array of ones of data type classname. classname is a string specifying the data type of the output. classname can have the following values: 'double', 'single', 'int8', 'uint8', 'int16', 'uint16', 'int32', 'uint32', 'int64', or 'uint64'.
x = ones(2,3,'int8');
![]() | onCleanup | open | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |