function x = randomPSK(n, len) % symbols: nth roots of unity % i.e. solutions to polynomial x^n - 1 = 0 symbols = roots([1 zeros(1, n-1) -1]); x = zeros(1, len); for i = 1:len x(i) = randomChoice(symbols); end end function x = randomChoice(arr) i = randi(length(arr)); x = arr(i); end