Description:
Create a multidimensional matrix where all the elements are1.
Syntax:
ones(n1,n2,…)
Note:
An external library function (See External Library Guide) where ni defines sizes of dimensions in order. The function creates a new n*n square matrix when there is only one parameter n.
Parameter:
ni |
A positive integer. |
Return value:
Sequence
Example:
|
A |
|
||||
1 |
=ones(4,3) |
Generate a 4*3 matrix whose elements are all 1. |
||||
2 |
=ones(3) |
Generate a matrix of size 3 whose elements are all 1. |
||||
3 |
=ones(4,3,5) |
Generate a multidimensional matrix whose elements are all 1. |