hi,,is there any way,I can generate a vector with 10 bit with only zero and 25?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
nafila aytija
il 23 Mag 2016
Commentato: Walter Roberson
il 23 Mag 2016
the vector should be like this, A=[0 0 25 25 25 0 0 25 0]...or anything that has only zero and 25.number of 25 is not important..TIA
0 Commenti
Risposta accettata
Walter Roberson
il 23 Mag 2016
TheConstant = 25;
HowMany = 10;
binary = rand(1,HowMany) < 0.5;
result = binary * TheConstant;
Or in short,
result = (rand(1,10) < 0.5) * 25;
2 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Logical 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!