BER/SNR plots for discrete BPSK over AWGN
[4yp.git] / randomPSK.m
1 function x = randomPSK(n, len)
2   % symbols: nth roots of unity
3   % i.e. solutions to polynomial x^n - 1 = 0
4   symbols = roots([1 zeros(1, n-1) -1]);
5
6   x = zeros(1, len);
7   for i = 1:len
8     x(i) = randomChoice(symbols);
9   end
10 end
11
12 function x = randomChoice(arr)
13   i = randi(length(arr));
14   x = arr(i);
15 end