ones
Array of all ones
ones
- It returns 1.
ones(n)
n
should be non-negative integer.- It returns an
n
-by-n
matrix containing all ones. - If
n
is not positive, it returns an empty array. - If
n
is not integer,n
would be rounded towards zero. - It does not accept ±
nan
, or ±inf
as its argument.
ones(s1,s2,...,sn)
s1
,s2
, ...,sn
should be non-negative integers.- It returns an array of size [
s1
s2
...sn
] that contains all ones. - If any of
s1
,s2
, ...,sn
is not positive, it returns an empty matrix. - Non-integer
s1
,s2
, ...,sn
would be rounded towards zero.
ones(sizeVec)
- It returns an array of size specified by the vector
sizeVec
. The array contains all ones. - If any element of
sizeVec
is not positive, it returns an empty matrix. Non-integer element ofsizeVec
would be rounded towards zero.