Do we have any Fucntion which can generate +1 and -1 randomly????
11 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
A P S
il 26 Ott 2014
Modificato: Mohammad Abouali
il 26 Ott 2014
I am using the following thing to generate it...
a=rand(1,10);
b=round(a);
b( b==0 )=-1;
So is there any other best way to genrate +1 and -1 randomly
0 Commenti
Risposta accettata
Mohammad Abouali
il 26 Ott 2014
Modificato: Mohammad Abouali
il 26 Ott 2014
I don't think there is any function doing that.
Here is another approach:
sign(rand(1,10)-0.5)
or
(-1).^(round(rand(1,10)))
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements 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!