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

1 view (last 30 days)

Accepted Answer

Image Analyst
Image Analyst on 12 Apr 2015
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;

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!