为不同的调制方案设计一个单载波系统(映射器-信道-去映射器)(Matlab代码实现)

欢迎来到本博客❤️❤️

博主优势:博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

本文目录如下:

目录

1 概述

2 运行结果

3 参考文献

4 Matlab代码实现


1 概述

本代码为不同的调制方案(BPSK-QPSK(Gray-coded&binary coded)-8PSK-16QAM-BFSK)设计了一个单载波系统(映射器-信道-去映射器),并计算实际BER和理论BER并比较结果。

2 运行结果

 

 

 

主函数部分代码:

clear all
clc

%%%%%%%%%%%%%%%%% generating bits %%%%%%%%%%%%%%%%%%%
stream_of_bits = 100000 ;
Random_bits = randi([0 1] , 1 , stream_of_bits) ;
%---------------------- 1)BPSK -------------------------- 
%%%%%%%%%%%%%%% Mapper %%%%%%%%%%%%%%%%%%%
mapped_symbols = Random_bits .*2 - 1 ; %mapping bits to 1 and -1
%%%%%%%%%%%%%%%%% AWGN channel %%%%%%%%%%%%%%%
BER_BPSK = [] ;
theoritical_BER_BPSK = [] ;
snr = [-2 : 5] ; %range of snr in dB
Eb=1; %bit Energy
No = Eb./(10.^(snr/10));
for i = 1 : length(snr)
AWGN = randn(1,stream_of_bits)*sqrt(No(i)/2); %generating gaussian noise of mean zero and variance 1 
recieved_signal = mapped_symbols + AWGN ; %Y=X+N
%%%%%%%%%%% Demapper %%%%%%%%%%%%%%%%%%%%%%
demapped_signal = [] ;
for k = 1 : stream_of_bits
if recieved_signal(k) >= 0 %zero is the threshold (-1+1)/2
demapped_signal = [demapped_signal 1] ;
else
demapped_signal = [demapped_signal 0] ;
end
end
%%%%%%%%%%% BER calculation %%%%%%%%%%%%%%%%%%%%
error = abs(demapped_signal - Random_bits);
BER_BPSK = [BER_BPSK sum(error)/stream_of_bits] ;
theoritical_BER_BPSK = [theoritical_BER_BPSK 0.5*erfc(sqrt(1/No(i)))];
end
%%%%%%%%%%%%% plotting %%%%%%%%%%%%%%%%%%%
figure(1)
semilogy(snr,BER_BPSK , '-o','linewidth',2 ) ;
hold on
semilogy( snr , theoritical_BER_BPSK ,'-p','linewidth',2) ;
xlabel('Eb/No');
ylabel('BER');
legend('tight upper bound of BER' , 'theoretical BER ') ;
grid on
title('BPSK Modulation');
%---------------------- 2)8PSK -------------------------
%%%%%%%%%%%%%%%%%%%%%%% Mapper %%%%%%%%%%%%%%%%%%%%%%%%

PSK8_mapped = zeros(1 , (stream_of_bits-1)/3) ;
for i = 1 : (stream_of_bits-1)/3

    if Random_bits (i*3-2 : i*3) == [0 0 0]

        PSK8_mapped(i) = cos(0)+j*sin(0);

    elseif Random_bits (i*3-2 : i*3) == [0 0 1]
        PSK8_mapped(i) = cos(pi/4)+j*sin(pi/4);

    elseif Random_bits(i*3-2 : i*3) ==[0 1 1]

        PSK8_mapped(i) = cos(pi/2)+j*sin(pi/2);

    elseif Random_bits(i*3-2 : i*3) ==[0 1 0]

        PSK8_mapped(i) = cos(3*pi/4)+j*sin(3*pi/4);

    elseif Random_bits(i*3-2 : i*3) ==[1 1 0]

        PSK8_mapped(i) = cos(pi)+j*sin(pi);

    elseif Random_bits(i*3-2 : i*3) ==[1 1 1]

        PSK8_mapped(i) = cos(5*pi/4)+j*sin(5*pi/4);

    elseif Random_bits(i*3-2 : i*3) ==[1 0 1]

        PSK8_mapped(i) = cos(3*pi/2)+j*sin(3*pi/2);

    elseif Random_bits(i*3-2 : i*3) ==[1 0 0]

        PSK8_mapped(i) = cos(7*pi/4)+j*sin(7*pi/4);
end
end

3 参考文献

[1]宋铁成,尤肖虎,沈连丰.基于OFDM系统信号处理方式的高速单载波系统[J].东南大学学报(自然科学版),2002(02):151-155.

部分理论引用网络文献,若有侵权联系博主删除。

4 Matlab代码实现

你可能感兴趣的:(信号处理,matlab,数学建模,开发语言)