random numbers can be divided b
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
fatima alansari
il 15 Giu 2019
Risposto: Star Strider
il 15 Giu 2019
hello,
how can i generate random numbers within a range that all generated numbers can be divided by 5??
meaning:
random number = r
r%5 = 0
regards
0 Commenti
Risposta accettata
Star Strider
il 15 Giu 2019
Try this:
r5 = randi(10,1,20)*5; % Creates 20 Random Integers From 5 To 50, All Of Which Can Be Divided Evenly By 5
Test = rem(r5,5)
The ‘Test’ vector will have elements only equal to 0.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Random Number Generation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!