Random Matrix in Matlab

randi() function is used to retrieve an array of integer, valued from give list in order of m*n dimensions used as :
randi([<start range> <ending range>],<number of rows>,<number of columns>)

Example

>> randi([2 6],2,3) % elements 2 to 6 (randomly) in matrix form of 2 rown and 3 columns

ans =

     3     5     6
     5     3     2

>> randi([1 100],3,4) % elements 1 to 100 (randomly) in matrix form of 3 rown and 4 columns

ans =

    67    28    49    55
    89    95    14    84
     5    87     8    19
Share

You may also like...