Wednesday, July 6, 2011

Generate a controlled random number in matlab

The main idea here is to generate a random number knowing the minimum and maximum limits, also the size.
The command to do it is
randi([imin,imax],[m,n])
where :
imin: is the minimum number
imax: is the maximum number
m: is the rows in the array (which determine the result size)
n : is the columns in the array (which determine the result size)

a useful application for this, is when you want to generate random numbering in Hex.
at this point you can choose, the above function and then use the dec2hex

No comments:

Post a Comment