Although the Jonas solution is really nice, randi not part of some of the earlier versions of MATLAB. I believe all versions have rand . A solution using rand would be:
randomIntergers = floor(a + (b-a+1) .* rand(20,1));
where [a, b] is the range of values ββthat you want to distribute.
If you use round(a + (ba)) , you will get an uneven effect on the values ββof "a" and "b". This can be confirmed using the hist() function. This is due to the fact that the domain that is displayed in "a" and "b" is two times smaller for all other members of the range.
source share