%function rate=digask(M, SNR) M = 4; % Use 4-ary modulation. Fd = 1; % Assume the original message is sampled % at a rate of 1 sample per second. Fs = 1; % The modulated signal will be sampled % at a rate of 1 samples per second. N =10000; %number of bits generated SNR = 10; %signal-to-noise ratio in dB x = randint(N,1,M); % Random digital message y = dmodce(x,Fd,Fs,'ask',M); % Use M-ary PSK modulation to produce y. ynoisy = y + (1/SNR)*randn(Fs*N,1) + (1/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,'ask',M); % Demodulate y to recover the message. [s, rate] = symerr(x,z); % Check symbol error rate.