# Obtaining Desired Dimensioned Matrices With Same Numbers In MatLab®(Illustrated Expression)

by,

There are very useful Matlab® codes to obtain specific matrices in a short way which makes Matlab® is a very useful tool to deal with matrices. One of these commands is the ‘repmat()’ command that you can use to create matrices in desired dimensions with the desired same number. In this article, we will explain the use of the ‘repmat()’ command in Matlab® to obtain these matrices.

## How To Use ‘repmat()’ Command In Matlab®?

``````>> a = repmat(3,5,5)
b = 3.*a

a =

3     3     3     3     3
3     3     3     3     3
3     3     3     3     3
3     3     3     3     3
3     3     3     3     3

b =

9     9     9     9     9
9     9     9     9     9
9     9     9     9     9
9     9     9     9     9
9     9     9     9     9

>> ``````

We created the ‘a’ matrix by using the ‘repmat()’ command in Matlab® as shown above. If you look at the ‘a’ variable as shown above, a 5×5 matrix that includes only the number of 3 is created. So as you understand that, you need to type the number that you want first, and the dimensions of the matrix that you want respectively inside the ‘repmat()’ command in Matlab®.

We multiplied the matrix ‘a’ with 3 then we assigned it to the variable ‘b’ as shown above. If you look at the result, the whole element of matrix ‘a’ is multiplied by 3 which means we can do mathematical operations with matrices that created with the ‘repmat()’ command in Matlab®.

## Conclusion

So the use of the ‘repmat()’ command is very simple like this in Matlab®.

Do not forget to leave your comments and questions below about the ‘repmat()’ command in Matlab® below.

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