MATLAB: Hello Please help how to generate a single random number between 6 and 8

random numbers

matlab

Best Answer

Did you happen to look up rand() in the help and see the example:
Create a vector of 1000 random values. Use the rand function to draw the values from a uniform distribution in the open interval, (50,100).
a = 50;
b = 100;
r = (b-a).*rand(1000,1) + a;
So your code would be
r = 2 .* rand(1) + 6;
Related Question