How To Generate Random Numbered Matrix In MatLab®(Illustrated Expression)

1 min reading time..

In Matlab®, you can obtain various kinds of matrices by using also various kinds of commands. Also, you can obtain even a matrix that comprises randomly obtained elements inside it. This command generates random element matrices called the ‘rand’ command. The use of the ‘rand’ command is very easy. We gave basic examples below that you can understand how to use the ‘rand’ command in Matlab® and which kinds of matrices in Matlab® by using the ‘rand’ command.

YOU CAN LEARN MatLab® IN MECHANICAL BASE; Click And Start To Learn MatLab®!

How To Use Rand Command In Matlab®?

>> v = rand(3,5)
z = 5.*v
d = 5.*rand(5,6)

v =

    0.8147    0.9134    0.2785    0.9649    0.9572
    0.9058    0.6324    0.5469    0.1576    0.4854
    0.1270    0.0975    0.9575    0.9706    0.8003

z =

    4.0736    4.5669    1.3925    4.8244    4.7858
    4.5290    3.1618    2.7344    0.7881    2.4269
    0.6349    0.4877    4.7875    4.8530    4.0014

d =

    0.7094    3.2787    3.7887    3.5302    4.1173    2.1937
    2.1088    0.1786    3.7157    0.1592    3.4741    1.9078
    4.5787    4.2456    1.9611    1.3846    1.5855    3.8276
    3.9610    4.6700    3.2774    0.2309    4.7511    3.9760
    4.7975    3.3937    0.8559    0.4857    0.1722    0.9344


As you can see from the example above about the ‘rand’ command in Matlab®, the general use of it only typing rand then typing dimensions of the matrix inside parentheses right after it as at the variable v. You can see the variable v result that the 3×5 matrix that comprises randomly created numbers between 0 and 1.

Also, you could do mathematical calculations with random numbered matrices that you created with the ‘rand’ command in Matlab® as in the z variable above. You can see the result that the whole elements of the variable v matrix are simply multiplied with the number of 5.

Also, you can directly use the ‘rand’ command in Matlab® in mathematical calculations as in d variable. 5×6 dimensioned matrix is created via ‘rand’ command then this directly multiplied with the number of 5 as you can see from the result of variable d.


So you can obtain various kinds of matrices that comprise randomly created numbers in Matlab®.

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

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

This article is prepared for completely educative and informative purposes. Images used courtesy of Matlab®

Your precious feedbacks are very important to us.

There are no comments for this article yet! You can make the first comment.
Leave a Comment