Documente Academic
Documente Profesional
Documente Cultură
-20
Magnitude(db)
-40
-60
-80
-100 -6
-4
-2
0 Frequency (Hz)
4 x 10
6
7
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.
Transmitted Waveform
Resultant waveform for 20 samples 2
1.5
0.5
-0.5
-1
-1.5 0
20
40
60
80
100
120
140
160
Eye Diagram
Eye diagram(100 samples taken for proper construction) 2 1.5 1 0.5 0 -0.5 -1 -1.5 -2
10
12
14
16
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)
Scatter plot 2
1.5
0.5
Quadrature
-0.5
-1
-1.5
-2 -2
-1.5
-1
-0.5
0 In-Phase
0.5
1.5
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
%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);
pbiterrortheo(count6)=qfunc(sqrt(2*(10^(Eb_No/10))));; count6=count6+1; end figure(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');
BER and SER plot versus Eb/No SER BER Theoretical BER
10
-2
10
-3
10
-4
10
-5
10
-6
5 Eb/No(db)
10
Conclusion
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 not obtained from any other source