Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

OPISIS_LAB1

.pdf
Скачиваний:
29
Добавлен:
24.12.2021
Размер:
1.09 Mб
Скачать

if iscolumn(s), s=s.'; end; %to return the result in same dim as 's' gamma = 10ˆ(SNRdB/10); %SNR to linear scale

if nargin==2, L=1; end %if third argument is not given, set it to 1 if isvector(s),

P=L*sum(abs(s).ˆ2)/length(s);%Actual power in the vector else %for multi-dimensional signals like MFSK

P=L*sum(sum(abs(s).ˆ2))/length(s); %if s is a matrix [MxN] end

N0=P/gamma; %Find the noise spectral density if(isreal(s)),

n = sqrt(N0/2)*randn(size(s));%computed noise else

n = sqrt(N0/2)*(randn(size(s))+1i*randn(size(s)));%computed noise end

r = s + n; %received signal

if iscolumn(s_temp), r=r.'; end;%return r in original format as s end

function [SER] = ser_awgn(EbN0dB,MOD_TYPE,M,COHERENCE) %Theoretical Symbol Error Rate for various modulations over AWGN %EbN0dB - list of SNR per bit values

%MOD_TYPE - 'BPSK','PSK','QAM','PAM','FSK'

%M - Modulation level for the chosen modulation

%- For PSK,PAM,FSK M can be any power of 2

%- For QAM M must be even power of 2 (square QAM only) %Parameter COHERENCE is only applicable for FSK modulation %COHERENCE = 'coherent' for coherent FSK detection

%= 'noncoherent' for noncoherent FSK detection

gamma_b = 10.ˆ(EbN0dB/10); %SNR per bit in linear scale gamma_s = log2(M)*gamma_b; %SNR per symbol in linear scale SER = zeros(size(EbN0dB));

6.1 AWGN channel 163 switch lower(MOD_TYPE) case 'bpsk'

SER=0.5*erfc(sqrt(gamma_b)); case {'psk','mpsk'}

if M==2, %for BPSK SER=0.5*erfc(sqrt(gamma_b)); else

if M==4, %for QPSK Q=0.5*erfc(sqrt(gamma_b)); SER=2*Q-Q.ˆ2; else %for other higher order M-ary PSK SER=erfc(sqrt(gamma_s)*sin(pi/M));

end end

case {'qam','mqam'}

SER = 1-(1-(1-1/sqrt(M))*erfc(sqrt(3/2*gamma_s/(M-1)))).ˆ2; case {'fsk','mfsk'}

if strcmpi(COHERENCE,'coherent'), for ii=1:length(gamma_s),

fun = @(q) (0.5*erfc((-q - sqrt(2.*gamma_s(ii)))/sqrt(2))).ˆ(M-1).* 1/sqrt(2*pi).*exp(-q.ˆ2/2);

SER(ii) = 1-integral(fun,-inf,inf); end

else %Default compute for noncoherent for jj=1:length(gamma_s),

summ=0;

for i=1:M-1,

n=M-1; r=i; %for nCr formula summ=summ+(-1).ˆ(i+1)./(i+1).*prod((n-r+1:n)./(1:r)).*exp(-i./(i +1).*gamma_s(jj));

end

SER(jj)=summ; %Theoretical SER for non-coherent detection end

end

case {'pam','mpam'} SER=2*(1-1/M)*0.5*erfc(sqrt(3*gamma_s/(Mˆ2-1))); otherwise

display 'ser_awgn.m: Invalid modulation (MOD_TYPE) selected' end

end

function [ser] = ser_rayleigh(EbN0dB,MOD_TYPE,M)

%Compute Theoretical Symbol Error rates for MPSK or MQAM modulations %EbN0dB - list of SNR per bit points

%MOD_TYPE - 'MPSK' or 'MQAM'

%M - Modulation level for the chosen modulation

%- For MPSK M can be any power of 2

%- For MQAM M must be even power of 2 (square QAM only) gamma_b = 10.ˆ(EbN0dB/10); %SNR per bit in linear scale gamma_s = log2(M)*gamma_b; %SNR per symbol in linear scale switch lower(MOD_TYPE)

case {'bpsk'}

ser = 0.5*(1-sqrt(gamma_b/(1+gamma_b))); case {'mpsk','psk'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = sin(pi/M).ˆ2;

fun = @(x) 1./(1+(g.*gamma_s(i)./(sin(x).ˆ2))); %MGF ser(i) = (1/pi)*integral(fun,0,pi*(M-1)/M);

end

case {'mqam','qam'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = 1.5/(M-1);

fun = @(x) 1./(1+(g.*gamma_s(i)./(sin(x).ˆ2)));%MGF

ser(i) = 4/pi*(1-1/sqrt(M))*integral(fun,0,pi/2)-4/pi*(1-1/sqrt(M))ˆ2* integral(fun,0,pi/4);

end

case {'mpam','pam'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = 3/(Mˆ2-1);

fun = @(x) 1./(1+(g.*gamma_s(i)./(sin(x).ˆ2)));%MGF ser(i) = 2*(M-1)/(M*pi)*integral(fun,0,pi/2);

end end end

function [ser] = ser_rician(EbN0dB,K_dB,MOD_TYPE,M)

%Compute Theoretical Symbol Error rates for MPSK or MQAM modulations %EbN0dB - list of SNR per bit points

%K_dB - K factor for Rician fading in dB %MOD_TYPE - 'MPSK' or 'MQAM'

%M - Modulation level for the chosen modulation

%- For MPSK M can be any power of 2

%- For MQAM M must be even power of 2 (square QAM only) gamma_b = 10.ˆ(EbN0dB/10); %SNR per bit in linear scale gamma_s = log2(M)*gamma_b; %SNR per symbol in linear scale

K=10ˆ(K_dB/10); %K factor in linear scale switch lower(MOD_TYPE)

case {'mpsk','psk'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = sin(pi/M).ˆ2;

fun = @(x) ((1+K)*sin(x).ˆ2)/((1+K)*sin(x).ˆ2+g*gamma_s(i)).*exp(-K*g* gamma_s(i)./((1+K)*sin(x).ˆ2+g*gamma_s(i))); %MGF

ser(i) = (1/pi)*integral(fun,0,pi*(M-1)/M);

end

case {'mqam','qam'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = 1.5/(M-1);

fun = @(x) ((1+K)*sin(x).ˆ2)/((1+K)*sin(x).ˆ2+g*gamma_s(i)).*exp(-K*g* gamma_s(i)./((1+K)*sin(x).ˆ2+g*gamma_s(i))); %MGF

ser(i) = 4/pi*(1-1/sqrt(M))*integral(fun,0,pi/2)-4/pi*(1-1/sqrt(M))ˆ2* integral(fun,0,pi/4);

end

case {'mpam','pam'}

ser = zeros(size(gamma_s));

for i=1:length(gamma_s), %for each SNR point g = 3/(Mˆ2-1);

fun = @(x) ((1+K)*sin(x).ˆ2)/((1+K)*sin(x).ˆ2+g*gamma_s(i)).*exp(-K*g* gamma_s(i)./((1+K)*sin(x).ˆ2+g*gamma_s(i))); %MGF

ser(i) = 2*(M-1)/(M*pi)*integral(fun,0,pi/2); end

end end

Соседние файлы в предмете Основы построения инфокоммуникационных систем и сетей