Special Arrays in MATLAB
In this section, we will discuss some functions that create some special arrays. For all these functions, a single argument creates a square array, double arguments create rectangular array.
The zeros() function creates an array of all zeros:
For example:
zeros(5)
MATLAB will execute the above statement and return the following result:
ans =
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
The ones() function creates an array of all ones:
For example:
ones(4,3)
MATLAB will execute the above statement and return the following result:
ans =
1 1 1
1 1 1
1 1 1
1 1 1
No comments:
Post a Comment