dimanche 25 octobre 2015

how to generate sequence include 1 or -1 in matlab?

I want to know how randomly generate a sequence either -1 or 1

for example:

[1 1 -1 -1] or
[-1 1 -1 1 1 1 1 -1 ] or 
[-1 1 1 -1 1 -1 -1] are all I expected.

but [-1 0 1 -1 -1 ] or [2 1 -1 -1 1 1 ] are not what I want.

Thank u guys.




Aucun commentaire:

Enregistrer un commentaire