jeudi 16 avril 2015

Generating a Pseudo-random sequence of plus/minus 1 integers

Can anybody help me create a simple pseudo-random sequence of +-1 integers with length 1000 using Matlab?


I.e. a sequence such as



-1 -1 1 1 -1 -1 1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 1


I tried using this code below but this is the RANGE -1 to 1, which includes 0 values. I only want -1 and 1. Thanks



x = randi([-1 1],1000,1);




Aucun commentaire:

Enregistrer un commentaire