Generating vector and made it variable
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
How i could generate a vector of equally likely 1 and -1 values and this vector has more than 1000 values. i want to make this vector variable that can be modified in the begining of the script
x = -1 : 0.001 : 1;
0 Kommentare
Antworten (1)
Steven Lord
am 17 Okt. 2019
Do you want exactly the same number of +1 and -1 values or do you just want each element to have an equal probability of being +1 or -1? For the former, make a vector that has the correct number of +1 and -1 elements (not randomly arranged) then use the output from randperm to shuffle it. For the latter, use randi to make a vector of 1's and 2's then replace all the 2's with -1.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!