Hello every one, How can I generate randomly only one number between two values (e.g.: 0.01-1)each time?

2 views (last 30 days)
a=ran(0.2,1.12)
b= ran(0.01,0.1)
function T = ran(min,max)
T= fix((max-min).*rand(1,1) + min)+1;
end
This code doesn't give me real number, It just give only integer number.
for example i want give me for a= 0.5 or 1.11 or any real number, and same for b=0.02 or 0.06 and so on.
i have use this code in this code: new{'LTE','Jitter'}=ran(0.6,4);
Thank you in advanced

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jan 2022
Remove the fix() call. fix() asks to take the integer portion of the value (rounding towards 0)
  4 Comments

Sign in to comment.

More Answers (0)

Categories

Find more on Tables 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!