How can I generate a random number in MATLAB between 13 and 20?
If you need a floating random number between 13 and 20
(20-13).*rand(1) + 13
If you need an integer random number between 13 and 20
floor((21-13).*rand(1) + 13)
Note: Fix problem mentioned in comment "This excludes 20" by replacing 20 with 21
If you are looking for Uniformly distributed pseudorandom integers use:
randi([13, 20])
Generate values from the uniform distribution on the interval [a, b].
r = a + (b-a).*rand(100,1);