Create a number between specific values
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Davidra Fantarina ANDRIAMISAINA
am 9 Mär. 2018
Kommentiert: Jan
am 9 Mär. 2018
I want to create a random or not value between specific values:
I have three double a,b,c a>b>c
and i want d number to be (a+c)/2<d<a
0 Kommentare
Akzeptierte Antwort
Jan
am 9 Mär. 2018
Bearbeitet: Jan
am 9 Mär. 2018
A random value between the two limits:
lim1 = (a + c) / 2;
lim2 = a;
d = lim1 + rand * (lim2 - lim1)
3 Kommentare
Walter Roberson
am 9 Mär. 2018
Yes. rand() can never be exactly 0 or exactly 1, so d can never be exactly lim1 or exactly lim2.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!