Generating Zeros Matrix in Matlab

People use matricesiIn mathematical calculations in Matlab®. So there are lots of easy matrices generating commands in Matlab®. Sometimes users needed to generate big matrices that include only the number of 0 in all elements inside it. You can generate this kind of matrix with a special command ‘zeros’. Also, this is the command that the users could obtain matrices that comprises only the number ‘0’ inside them. You can follow the basic example below to understand how the ‘zeros’ code works in Matlab®. So you will see that generating a zeros matrix in Matlab is very simple.

Check: Recommended Books to Learn Matlab®

How to use zeros() Command in Matlab?

>> v = zeros(2,3)
z = 5.*v
d = 5.*zeros(4,5)

v =

     0     0     0
     0     0     0

z =

     0     0     0
     0     0     0

d =

     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0
     0     0     0     0     0


Firstly, as you can see above, we gave three examples about the usage of the ‘zeros’ command in Matlab®. The general use of the ‘zeros’ command in Matlab® is like the v variable above. You just type zeros then the dimensions of your matrix inside the parentheses right after it. You can see the v variable that includes only the number of 0 inside it.

Also, you can make mathematical calculations as shown with the z variable above. We just multiplied v by 5 then you can see all the numbers are multiplied with 5 in Matlab®.

Also, you can directly do mathematical calculations with ‘zeros’ code as shown by the d variable. So you can obtain various matrices by using the ‘zeros’ command as shown above in Matlab®.

What is Zeros Matrix?

Zeros matrix is a type of matrix in that all the elements are zero. People use the zeros matrix in different mathematical and algebraic calculations.

In addition, sometimes, you need to use the zeros matrix lots of time in complex mathematical calculations. And, typing zeros matrices every time is a hard thing. You can use the zeros() command in Matlab to create zeros matrices to implement them to the mathematical calculations.

Above all, Matlab provides various kinds of useful commands and functions. You can implement these commands and functions to solve complex problems you have. You can check the other useful features of Matlab®.


So, the use of the zeros() command in Matlab to generate a zeros matrix is a very simple task. You can use this command in your all mathematical calculations.

Finally, do not forget to leave your comments and questions below about the use of the ‘zeros()’ command in Matlab® below. 

If you want further coding examples about the ‘zeros()’ command in Matlab®, inform us in the comments.

We prepared this article for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.


Leave a Reply

Your email address will not be published. Required fields are marked *