zeros() command creates an array of all zeros, after reading this MATLAB zeros topic, you will know the theory, and examples, and you will understand how to create a matrix with all elements zero in MATLAB.
Syntax:
zeros(n) zeros(n,m)
- Foe zeros(n), represents n columns and n rows.
- Foe zeros(n,m), represents the n rows and m columns.
Example: To create 2×2 zeros matrix.
The statement to create zeros matrix in MATLAB is given as
zeros(2)
Output:
ans = 0 0 0 0
Example: To create 2×3 zeros matrix.
zeros(2,3)
Output:
ans = 0 0 0 0 0 0