I wanna randomly select 1 by 6 matrix elements between -1 and 1.
For example, [-1 1 -1 1 1 1]
How do I select it??
Create a vector of possible values, and use randi to generate random indices into that vector.
Choices = [-1 1];
Index = randi(length(Choices), 1, 6);
Choices(Index)
ans =
1 1 1 -1 1 -1
round and rand for this type of thing in the past, but this is much better!