Commit | Line | Data |
---|---|---|
54255896 AIL |
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 |