In Matlab, I need to generate signs (i.e. {-1,1}) randomly. I've come out with a solution, but I need this to be lighter. My solution implies calling two functions, a multiplication (although it's a binary shift) and a subtraction.
This is my code:
L=1000; x=2*round(rand(L,1))-1;
Aucun commentaire:
Enregistrer un commentaire