Upload
sourav-chatterjee
View
215
Download
0
Embed Size (px)
Citation preview
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 1/10
EE6170 Introduction to Wireless and Cellular Communications
Computer Assignment 1
SOURAV CHATTERJEE
EE12M016
1)
Function for generating SRRC Pulse
function [h]=rrcpulse(lowlim,incre,highlim,r,tsamp) count=1; for n=lowlim:incre:highlim
if (n==0) h(count)=1-r+(4*r/pi);
elseif (n==((8*tsamp)/(4*r))||n==(-(8*tsamp)/(4*r))) h(count)=(r/sqrt(2))*((1+2/pi)*sin(pi/(4*r))+(1-2/pi)*cos(pi/(4*r)));
else h(count)=(sin(pi*(1-r)*(n/(8*tsamp)))+4*r*(n/(8*tsamp))*cos(pi*(1+r)*(n/(8*tsamp))))/(pi*(n/(8*tsamp))*(1-16*r*r*(n/(8*tsamp))*(n/(8*tsamp))));
end count=count+1;end
Code for generating frequency responseclc;
clear all; r1=.35; r2=.7; r3= 1; %srrc roll off factor tsym=1/25000; %symbol time tsamp=tsym/8; %sampling timef=(2*pi)/tsamp; x1=rrcpulse(-5*tsym,tsamp,5*tsym,r1,tsamp); x2=rrcpulse(-5*tsym,tsamp,5*tsym,r2,tsamp); %srrc pulse generated x3=rrcpulse(-5*tsym,tsamp,5*tsym,r3,tsamp); figure(1) h1=fft(x1); h11=fftshift(h1);
h2=fft(x2); h21=fftshift(h2); h3=fft(x3); h31=fftshift(h3); w=-40:1:40; plot((w*f),20*log10(abs(h11(w+41))), 'r*-',(w*f),20*log10(abs(h21(w+41))), 'b-',(w*f),20*log10(abs(h31(w+41))), 'g^-')%plotting of frequency response grid on; title('Frequency response of SRRC Pulse for different roll-off factors'); xlabel('Frequency (Hz)'); ylabel('Magnitude(db)'); legend('rolloff factor=.35','rolloff factor=.7','rolloff facor=1');
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 2/10
Plot of Frequency Response
2) Continuation of the above code
xrc=conv(x1,x1); %generate rc pulse by convolving two srrc
pulses count1=1; for a=40:(length(xrc)-41)
xrc1(count1)=xrc(a); %truncate for appropriate sampling count1=count1+1;
end d=randsrc(1,20); %take random sequence of 20 bits dup=zeros(1,8*20); %Generate the upsampled array for i=1:20
dup(8*(i-1)+1)= d(i); %Upsampling the signal by factor of 8 end result0=conv(dup,xrc1/8); %Convolving the result with rc pulse count2=1; for a=40:(length(result0)-41)
result1(count2)=result0(a); %Truncate for approproiate sampling count2=count2+1;
end figure(2) plot(result1,'*-') %Plot the generated waveform title('Resultant waveform for 20 samples'); figure(3) for i=1:20
c(i)=result1(8*(i-1)+1); end eyediag(result1,16); %Generate eye diagram' title('Eye diagram(100 samples taken for proper construction)');
Function for eye diagram
-6 -4 -2 0 2 4 6
x 107
-100
-80
-60
-40
-20
0
20Frequency response of SRRC Pulse for different roll-off factors
Frequency (Hz)
M a g n i t u d e ( d b )
rolloff factor=.35
rolloff factor=.7
rolloff facor=1
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 3/10
function eyediag(x,n) for i=1:(length(x)/n)
for j=1:n k(j)=x(n*(i-1)+j);
end plot(k)
hold on; end
Values obtained at ideal sampling points
Columns 1 through 4
-1.0064 0.9957 -0.9937 -1.0069
Columns 5 through 8
-0.9940 0.9937 0.9954 -1.0054
Columns 9 through 12
1.0044 -1.0068 0.9985 1.0042
Columns 13 through 16
0.9944 -1.0051 1.0071 0.9985
Columns 17 through 20
-0.9965 0.9978 1.0004 -0.9975
Sent Values
Columns 1 through 7
-1 1 -1 -1 -1 1 1
Columns 8 through 14
-1 1 -1 1 1 1 -1
Columns 15 through 20
1 1 -1 1 1 -1
Observations
We see that the sampled values are nearly equal to the sent values. So there is
no ISI in the bandlimited channel due to use of RC pulse shaping.
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 4/10
Transmitted Waveform
0 20 40 60 80 100 120 140 160-1.5
-1
-0.5
0
0.5
1
1.5
2 Resultant waveform for 20 samples
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 5/10
Eye Diagram
3)a)Continuation of the above code
%Generation of mdulating bits d1=randsrc(1,1024);%QPSK Symbol generation loopcount=1; for i=1:2:length(d1)-1
if(d1(i)==-1&&d1(i+1)==-1)
qpsk(loopcount)=exp(1i*pi/4); elseif(d1(i)==-1&&d1(i+1)==1) qpsk(loopcount)=exp(3*1i*pi/4);
elseif(d1(i)==1&&d1(i+1)==-1) qpsk(loopcount)=exp(-1i*pi/4);
else qpsk(loopcount)=exp(-3*1i*pi/4);
end loopcount=loopcount+1;
end dup2=zeros(1,(8*loopcount)); dup3=zeros(1,(8*loopcount)); %upsampling by factor of 8
for i=1:loopcount-1 dup2(8*(i-1)+1)= real(qpsk(i)); dup3(8*(i-1)+1)= imag(qpsk(i));
0 2 4 6 8 10 12 14 16-2
-1.5
-1
-0.5
0
0.5
1
1.5
2Eye diagram(100 samples taken for proper construction)
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 6/10
end %Generation of two orthogonal waveforms for real and imaginary part of QPSK %symbol qpsktx1lin=conv(dup2,x1); qpsktx1qu=conv(dup3,x1); %Truncation for appropriate sampling
count3=1; for a=40:(length(qpsktx1lin)-41) qpsktx1in(count3)=qpsktx1lin(a); qpsktx1qua(count3)=qpsktx1qu(a); count3=count3+1;
end
%addition of noise with Eb/No=6db SNR=9; qpskinrec=awgn(qpsktx1in,SNR); qpskqurec=awgn(qpsktx1qua,SNR);
for b=1:loopcount-1
qpskinrec1(b)=qpskinrec(8*(b-1)+1); qpskqurec1(b)=qpskqurec(8*(b-1)+1);
end qpskrec=qpskinrec1+1i*qpskqurec1; %plotting of received symbols scatterplot(qpskrec)
Scatterplot of received symbols
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 7/10
b,c)Continuation of code
%Calculation of signal power Eb=0; for f=1:length(qpsktx1in)
Eb=Eb+(qpsktx1in(f))^2; end Ps=Eb/length(qpsktx1in); count6=1; Eb_No_db=0:2:12; %BER and SER simulation for Eb_No=0:2:12
Ps_Pn=Eb_No+3; %Calculation of noise variance variance=Ps/(10^(Ps_Pn/10)); %generation of AWGN noise=sqrt(variance)*randn(1,length(qpsktx1in)); %addition of noise qpsktxinrec2=qpsktx1in+noise; qpsktxqurec2=qpsktx1qua+noise;
%Convolution of receives symbols with matched filter qpsktxinrec3=conv(qpsktxinrec2,x1); qpsktxqurec3=conv(qpsktxqurec2,x1); count4=1; %Truncation for appropriate sampling for a=40:(length(qpsktxinrec3)-41)
qpsktxinrec4(count4)=qpsktxinrec3(a); qpsktxqurec4(count4)=qpsktxqurec3(a); count4=count4+1;
end
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Q u a d r a t u r e
In-Phase
Scatter plot
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 8/10
%Extraction of received data for b=1:loopcount-1
qpskinrec5(b)=qpsktxinrec4(8*(b-1)+1); qpskqurec5(b)=qpsktxqurec4(8*(b-1)+1);
end qpskrec2=complex(qpskinrec5,qpskqurec5);
phase=angle(qpskrec2); %Maximum likelihood decoding of received samples for z=1:length(qpskrec2)
if phase(z)>0 && phase(z)<=(pi/2) qpskdec(z)=exp(j*pi/4);
end if phase(z)>(pi/2) && phase(z)<=pi
qpskdec(z)=exp(3*j*pi/4); end if phase(z)<=0 && phase(z)>(-pi/2)
qpskdec(z)=exp(-j*pi/4); end if phase(z)<=(-pi/2) && phase(z)>(-pi)
qpskdec(z)=exp(-3*j*pi/4); end end %Decoding of bits from decoded samples count5=1; for z1=1:length(qpskdec)
if qpskdec(z1)==exp(j*pi/4) qpskdec1(count5)=-1; qpskdec1(count5+1)=-1;
end if qpskdec(z1)==exp(3*j*pi/4)
qpskdec1(count5)=-1; qpskdec1(count5+1)=1;
end if qpskdec(z1)==exp(-j*pi/4) qpskdec1(count5)=1; qpskdec1(count5+1)=-1;
end if qpskdec(z1)==exp(-3*j*pi/4)
qpskdec1(count5)=1; qpskdec1(count5+1)=1;
end count5=count5+2;
end %Calculation of number of errors symerror=0; biterror=0; for k=1:length(qpskdec)
result1=abs(qpsk(k)-qpskdec(k)); if result1~=0
symerror=symerror+1; end
end for i=1:length(qpskdec1)
result2=abs(d1(i)-qpskdec1(i)); if result2~=0
biterror=biterror+1; end
end %Calculation of probability of error psymerror(count6)=symerror/length(qpskdec); pbiterror(count6)=biterror/length(d1);
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 9/10
pbiterrortheo(count6)=qfunc(sqrt(2*(10^(Eb_No/10))));; count6=count6+1;
endfigure(7) semilogy(Eb_No_db,psymerror,'r^-',Eb_No_db,pbiterror,'b*-',Eb_No_db,pbiterrortheo,'g^-')
title('BER and SER plot versus Eb/No'); xlabel('Eb/No(db)'); ylabel('Probability of error'); legend('SER','BER','Theoretical BER');
Plot of BER and SER versus Eb/No
Conclusion
0 1 2 3 4 5 6 7 8 9 1010
-6
10-5
10-4
10-3
10-2
10-1
BER and SER plot versus Eb/No
Eb/No(db)
SER
BER
Theoretical BE R
7/29/2019 EE12M016_assign1
http://slidepdf.com/reader/full/ee12m016assign1 10/10
The actual BER and SER curves come a little different from the theoretical
because we have not simulated over sufficient number of samples.
Honour Code
I certify that this assignment submission is my own work and notobtained from any other source