how do I generate a random signal with each point being -1 or +1 in MATLAB
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
to generate a s_n∈{+1,-1}
with an example:
1,-1,1,1,-1,1,-1,-1,-1,-1,1,1,-1,-1,1,-1
0 Kommentare
Akzeptierte Antwort
Rik
am 21 Okt. 2022
randi([0 1],1,N)*2-1
That should do it. Or even this:
sign(rand(1,N)-0.5)
Although it is possible that generates a 0 if rand happens to land exactly on 0.5.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!