%SANJEET KUMAR
%M.Tech(Telecommunication)
%NIT Calicut
clear;
clc;
M = 2;
k = log2(M);
fs = 1;
T = 1/fs;
t = 0:T:100;
nsamp = 5;
fftlength = 2^nextpow2(length(t));
ebno = 5;
filtorder = 20;
delay = filtorder/(nsamp*2);
rolloff = 0.5;
% square root raised cosine filter.
rrcfilter = rcosine(1,nsamp,'fir/sqrt',rolloff,delay);
x = randint(length(t),1); % Random binary data
ytx = pskmod(x,M);
ytx = rcosflt(ytx,1,nsamp,'filter',rrcfilter);
snr = ebno + 10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx, snr, 'measured');
% PSD estimation via welch method
figure(1);
h = spectrum.welch;
Hpsd= psd(h,ytx,'fs',fs);
plot(Hpsd);
title('POWER SPECTRAL DENSITY with sqrtRCF');
xlabel('frequency,f(hz)-->');
ylabel('(db/hz)-->');
% raised cosine filter.
rrcfilter = rcosine(1,nsamp,'fir',rolloff,delay);
x1 = randint(length(t),1);
ytx1 = pskmod(x1,M);
ytx1 = rcosflt(ytx1,1,nsamp,'filter',rrcfilter);
snr = ebno + 10*log10(k) - 10*log10(nsamp);% add some AWGN noise
ynoisy = awgn(ytx1, snr, 'measured');
% PSD estimation via welch method
figure(2);
h = spectrum.welch;
Hpsd= psd(h,ytx1,'fs',fs);
plot(Hpsd);
title('POWER SPECTRAL DENSITY with RCF');
xlabel('frequency,f(hz)-->');
ylabel('(db/hz)-->');
% Create a raised cosine nyquist filter.
rolloff = 0; % Rolloff factor of filter
rrcfilter = rcosine(1,nsamp,'fir',rolloff,delay);
x2 = randint(length(t),1);
ytx2 = pskmod(x1,M);
ytx2 = rcosflt(ytx2,1,nsamp,'filter',rrcfilter);
snr = ebno+10*log10(k) - 10*log10(nsamp);
ynoisy = awgn(ytx2, snr, 'measured');
% PSD estimation via Matlab welch method
figure(3);
h = spectrum.welch;
Hpsd= psd(h,ytx2,'fs',fs);
plot(Hpsd);
title('POWER SPECTRAL DENSITY with Nyquist');
xlabel('frequency,f(hz)-->');
ylabel('(db/hz)-->');