0% found this document useful (0 votes)
39 views

Matlab Assignment 3

Matlab program to simulate the symbol error performance and the bit error rate performance of the 8PSK communication system. Compare your simulated performance with the analytical expression for the symbol error probability (SER). (1) Plot your simulated SER curve and the analytical SER curve for QPSK in the same figure as functions of 10 log Eb/N0. (2) Plot your simulated BER curve for 8PSKand the analytical BER curve for BPSK in the same figure as functions of 10 log Eb/N0.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Matlab Assignment 3

Matlab program to simulate the symbol error performance and the bit error rate performance of the 8PSK communication system. Compare your simulated performance with the analytical expression for the symbol error probability (SER). (1) Plot your simulated SER curve and the analytical SER curve for QPSK in the same figure as functions of 10 log Eb/N0. (2) Plot your simulated BER curve for 8PSKand the analytical BER curve for BPSK in the same figure as functions of 10 log Eb/N0.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MATLAB ASSIGNMENT 3

Jeffin Varghese
10419091

clear all;
N = 30000; %No of bits
Ns = N/3; %No of symbols 8PSK;
sr2=sqrt(2);
GreyCode = [-1-1i -sr2 sr2*1i -1+1i -sr2*1i 1-1i 1+1i sr2 ];
EbNo = 0:2:10; %Eb/No;
L = 10.^(EbNo/20); %Eb.No in linear unit;
Pbsim= zeros(1, length(L)); %error probability for simulation;
Pssim= zeros(1, length(L)); %error probability for simulation;
Decision = zeros(1, N); %decision vector;
Nerror_bits= 0; %No of bits in simulation;
Npackets= 0; %No of packets in simulation;
Nerror_symbols= 0;
for n = 1:length(EbNo)
while(Nerror_symbols< 100) %No error bits greater than 100
bits = round(rand(1, N));
bits_1 = bits(1:3:end);
bits_2 = bits(2:3:end);
bits_3 = bits(3:3:end);
Signal = GreyCode(bits_1*4+bits_2*2+bits_3+1); %Generating transmitted
symbols;
Noise = randn(1, Ns)+1i*randn(1, Ns);
Rsig= sqrt(2)/sqrt(2)*sqrt(3)*L(n)*Signal+Noise;
Psig = angle(Rsig); %Phase of the signal;
index0 = find(Psig >= -pi/8 & Psig < pi/8);
index1 = find(Psig >= pi/8 & Psig < 3*pi/8);
index2 = find(Psig >= 3*pi/8 & Psig < 5*pi/8);
index3 = find(Psig >= 5*pi/8 & Psig <= 7*pi/8);
index4 = find(Psig > 7*pi/8 | Psig <= -7*pi/8);
index5 = find(Psig > -7*pi/8 & Psig <= -5*pi/8);
index6 = find(Psig > -5*pi/8 & Psig < -3*pi/8);
index7 = find(Psig > -3*pi/8 & Psig < -pi/8);
%Symbol errors;
Nerror_symbols= Nerror_symbols+length(find(Signal(index0) ~= sr2));
Nerror_symbols= Nerror_symbols+length(find(Signal(index1) ~= 1+1i));
Nerror_symbols= Nerror_symbols+length(find(Signal(index2) ~= sr2*1i));
Nerror_symbols= Nerror_symbols+length(find(Signal(index3) ~= -1+1i));
Nerror_symbols= Nerror_symbols+length(find(Signal(index4) ~= -sr2));
Nerror_symbols= Nerror_symbols+length(find(Signal(index5) ~= -1-1i));
Nerror_symbols= Nerror_symbols+length(find(Signal(index6) ~= -sr2*1i));
Nerror_symbols= Nerror_symbols+length(find(Signal(index7) ~= 1-1i));
Decision = zeros(1, N);
Decision(3*index0-2) = ones(1, length(index0));
Decision(3*index0-1) = ones(1, length(index0));
Decision(3*index0) = ones(1, length(index0));
Decision(3*index1-2) = ones(1, length(index1));
Decision(3*index1-1) = ones(1, length(index1));
Decision(3*index1) = zeros(1, length(index1));
Decision(3*index2-2) = zeros(1, length(index2));
Decision(3*index2-1) = ones(1, length(index2));
Decision(3*index2) = zeros(1, length(index2));
Decision(3*index3-2) = zeros(1, length(index3));
Decision(3*index3-1) = ones(1, length(index3));
Decision(3*index3) = ones(1, length(index3));
Decision(3*index4-2) = zeros(1, length(index4));
Decision(3*index4-1) = zeros(1, length(index4));
Decision(3*index4) = ones(1, length(index4));
Decision(3*index5-2) = zeros(1, length(index5));
Decision(3*index5-1) = zeros(1, length(index5));
Decision(3*index5) = zeros(1, length(index5));
Decision(3*index6-2) = ones(1, length(index6));
Decision(3*index6-1) = zeros(1, length(index6));
Decision(3*index6) = zeros(1, length(index6));
Decision(3*index7-2) = ones(1, length(index7));
Decision(3*index7-1) = zeros(1, length(index7));
Decision(3*index7) = ones(1, length(index7));
Nerror_bits= Nerror_bits+length(find(Decision ~= bits)); %counting bits in error;
Npackets= Npackets+1;
end
Pssim(n) = Nerror_symbols/(N*Npackets/3);
Pbsim(n) = Nerror_bits/(N*Npackets);
Nerror_symbols= 0;
Nerror_bits= 0;
Npackets= 0;
end
Ps_theory= erfc(L*sqrt(3)*sin(pi/8)); %Theoretical results;
Pb_theory_BPSK= 0.5*erfc(L);
figure;
semilogy(EbNo, Pssim, 'ro');
hold on
semilogy(EbNo, Pbsim, 'r>');
hold on
semilogy(EbNo, Ps_theory, '-*');
hold on
semilogy(EbNo, Pb_theory_BPSK, '.-');
hold of;
legend('P_S Simulated Result','P_B Simulated Result','8PSK Theoretical P_S','BPSK
Theoretical P_B');
xlabel('Eb/No (dB)');
ylabel('Probability of Error');
grid;

You might also like