Random integer numbers using random function
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
KnowledgeSeeker
le 10 Fév 2014
Commenté : KnowledgeSeeker
le 10 Fév 2014
Hi, I am trying to obtain 9 random integer numbers and want them to be appeared in this form
expectedoutpt = '989898989' '897676767'
any suggestion?
0 commentaires
Réponse acceptée
Mischa Kim
le 10 Fév 2014
Something like:
function ri = rnum()
ri = num2str(randi([1,9],1,9));
ri = ri(~isspace(ri));
end
Plus de réponses (1)
Jos (10584)
le 10 Fév 2014
Two strings of 9 random digits between 1 and 9 each (no 0?), stored in a row cell(?) array?
S = cellstr(char('0' + ceil(9*rand(2,9)))).'
Voir également
Catégories
En savoir plus sur Random Number Generation 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!