You could use the randi function to generate a random integer in a range, and then perform scaling and offset to convert it to what you want.
For example, take the following command
- randi(20) generates a number from 1 to 20
- 0.1*randi(20) generates a number from 0.1 to 2, in increments of 0.1
- 0.1*randi(20) + 2 generates a number from 2.1 to 4, in increments of 0.1
You can apply a similar principle to get the range you want.
Also, if you want to generate multiple numbers, you can use the second argument of the function. For example, to generate a 2-by-3 array of the same random numbers:
x = 0.1*randi(20,[2 3]) + 2
Finally, you mentioned binary numbers. You can always convert a decimal number to binary using the dec2bin function.
- Sebastian