Can Matlab give me a disturbance randomly from a% to b% of a number?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
Let say my number is 7, and I need to generate a randomly number from 5 to 400% of 7. Can Matlab give me the randomly numbers? Thank you in advance for your help!
Ben
0 commentaires
Réponse acceptée
Matt J
le 18 Fév 2017
Modifié(e) : Matt J
le 18 Fév 2017
ub=4*7; %upper bound
lb=.05*7; %lower bound
num=(ub-lb)*rand+lb
2 commentaires
John D'Errico
le 18 Fév 2017
Hmm. I interpret the lower limit differently from the question. You may be right though.
Plus de réponses (1)
John D'Errico
le 18 Fév 2017
Do you know how to generate uniform random numbers in an interval [x,y]? This is in the help for rand, so you should know, or be able to find out.
doc rand
Here, your limits are
[5,4*7]
since 4*7 is 400% of 7. Just read the help.
1 commentaire
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!