%function rate=digpsk(M, SNRdB) M = 8; % Use 16-ary modulation. Fd = 1; % Assume the original message is sampled % at a rate of 1 sample per second. Fs = 3; % The modulated signal will be sampled % at a rate of 3 samples per second. N = 1000; %number of bits generated SNRdB = 7; %signal-to-noise ratio in dB SNR = 10 ^ (SNRdB/10); x = randint(N,1,M); % Random digital message y = dmodce(x,Fd,Fs,'psk',M); % Use M-ary PSK modulation to produce y. ynoisy = y + (0.5/SNR)*randn(Fs*N,1) + (0.5/SNR)*j*randn(Fs*N,1); % Add some Gaussian noise. scatterplot(ynoisy,1,0,'b.'); % Create scatter plot from noisy data. z = ddemodce(ynoisy,Fd,Fs,'psk',M); % Demodulate y to recover the message. [s, rate] = symerr(x,z); % Check symbol error rate.