Next Post:

Difference Between Steel And Cast Iron

Matrices And Vectors With Randomly Created Elements In MatLab(Illustrated Expression)


Like in every programming language, Matlab has a command that creates a random number or numbers. But in Matlab, you can create matrices and vectors that includes randomly created elements inside it. In this article, we will show you how to create matrices or vectors that their elements are randomly created.

How To Create Matrices And Vectors That Includes Random Elements In Matlab?


Use of rand() command to create matrices and vectors in Matlab.

The ‘a’ is a matrice that created by random numbers as shown by orange arrow above in Matlab. It is a 3×2 matrix as shown by green arrow above and created with rand() command.

Also vector ‘b’ is randomly numbered vector that is created by rand() command again. Actually it is a 1×3 matrix but also means it is vector as shown by red arrow and yellow arrow above.

These ‘a’ matrix and ‘b’ vector is multiplied with integers as shown by red box above. Because rand() command in Matlab, creates random numbers between 0 and 1. You can do multiplication as above to obtain number between integers that you want. Multiplied vector and matrix could be seen by magenta arrow and blue arrow above.

The logic of creating matrices and vectors with rand() command in Matlab is like that.

Leave your questions and comments below!

  • Site Comments

At least 10 characters required.