Generating vectors of length N with only -1s and 1s.
1 view (last 30 days)
Show older comments
Aditya Petety
on 17 Jun 2019
Commented: Aditya Petety
on 17 Jun 2019
I want to generate some M number of vectors of length N with the entries restricted to -1s and 1s and the vectors should not be repetitive. Is it possible to do so? If yes, how?
0 Comments
Accepted Answer
Stephen23
on 17 Jun 2019
>> M = 5;
>> N = 19;
>> randi(0:1,M,N)*2-1
ans =
-1 1 -1 1 -1 -1 1 -1 1 -1 -1 1 -1 1 1 -1 -1 1 1
1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 -1 1 1 1 -1 1
-1 1 -1 1 1 1 1 -1 1 -1 -1 -1 1 -1 1 1 1 1 -1
1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 1 1 1 -1
-1 -1 1 -1 -1 -1 1 1 1 1 1 -1 -1 1 1 1 1 1 1
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!