4 семестр ИКТ 6 вариант / ЛР4 СПВТ
.docx
Лабораторная работа №4
Задание 1
clear all;clc;
close all;
N=100000;%Number of bits to transmit
EbN0dB = -4:2:6; % Eb/N0 range in dB for simulation
fc=100;%carrier frequency in Hertz
OF =8; %oversampling factor, sampling frequency will be fs=OF*fc
EbN0lin = 10.^(EbN0dB/10); %converting dB values to linear scale
BER = zeros(length(EbN0dB),1); %For BER values for each Eb/N0
a = rand(N,1)>0.5; %random bits - input to QPSK
[s,t] = qpsk_mod(a,fc,OF);%QPSK modulation
for i=1:length(EbN0dB)
Eb=OF*sum(abs(s).^2)/(length(s)); %compute energy per bit
N0= Eb/EbN0lin(i); %required noise spectral density from Eb/N0
n = sqrt(N0/2)*(randn(1,length(s)));%computed noise
r = s + n;%add noise
a_cap = qpsk_demod(r,fc,OF); %QPSK demodulation
BER(i) = sum(a~=a_cap.')/N;%Bit Error Rate Computation
end
%------Theoretical Bit Error Rate------------
theoreticalBER = 0.5*erfc(sqrt(EbN0lin));%Theoretical bit error rate
%-------------Plot performance curve-----------------------
figure;
semilogy(EbN0dB,BER,'k*','LineWidth',1.5); %simulated BER
hold on;
semilogy(EbN0dB,theoreticalBER,'r-','LineWidth',1.5);
title('Probability of Bit Error for QPSK modulation');
xlabel('E_b/N_0 (dB)');ylabel('Probability of Bit Error - P_b');
legend('Simulated', 'Theoretical');grid on;
Задание 2
clear
clc
close all;
nSym=2.4*10^6
EbN0dB = -4:2:6;
MOD_TYPE='FSK';
arrayOfM=[2,4,8,16,32];
COHERENCE = 'noncoherent'
plotColor =['b','g','r','c','m','k']; p=1;
legendString = cell(1,length(arrayOfM)*2);
for M = arrayOfM
k=log2(M);
EsN0dB = 10*log10(k)+EbN0dB;
SER_sim = zeros(1,length(EbN0dB
d=ceil(M.*rand(1,nSym));
s=modulate(MOD_TYPE,M,d,COHERENCE);
for i=1:length(EsN0dB)
r = add_awgn_noise(s,EsN0dB(i));
dCap = demodulate(MOD_TYPE,M,r,COHERENCE);
SER_sim(i) = sum((d~=dCap))/nSym;
end
SER_theory = ser_awgn(EbN0dB,MOD_TYPE,M,COHERENCE);
semilogy(EbN0dB,SER_sim,[plotColor(p) '*']);
hold on;
semilogy(EbN0dB,SER_theory,plotColor(p));
legendString{2*p-1}=['Sim ',num2str(M),'-',MOD_TYPE];
legendString{2*p}=['Theory ',num2str(M),'-',MOD_TYPE];
p=p+1;
end
legend(legendString);
xlabel('Eb/N0(dB)');
ylabel('SER (Ps)');
title(['Probability of Symbol Error for M-',MOD_TYPE,' over AWGN']);