基于Matlab模拟AWGN 信道上 OFDM附完整代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测 雷达通信  无线传感器

信号处理 图像处理 路径规划 元胞自动机 无人机  电力系统

⛄ 内容介绍

交频分复用 (Orthogonal Frequency Division Multiplexing OFDM) 是第四代 (the4th Generation,4G) 移动通信的核心技术,它的最大优点是对抗频率选择性衰落,同时又提高了频谱利用率。它不仅仅可以增加系统容量,更重要的是它能更好地满足多媒体通信要求,将包括语音、数据、影像等大量信息的多媒体业务通过宽频信道高品质地传送出去。 但是OFDM技术对频率偏移和相位噪声很敏感,所以同步是OFDM系统中的关键问题。缺乏必要的同步机制,各子频道的正交性就会受到破坏,从而引入子载波间干扰ICI(Intemal Channel Interference)。

⛄ 完整代码

%---------------------------------------------------------------------------------------------------

% In this example we show how OFDM system perform over AWGN channel. The

% simulation results will be checked with ones we obtain through

% theoritical analysis.

%

%---------------------------------------------------------------------------------------------------

% Initiliazation

clear         % clear all workspace variables

clc           % clear command window

close all     % close all open figures

mFileName     = mfilename;                              % Get mfile name

mFileNameFull = mfilename('fullpath');                  % Get mfile full name

mFileDirMain  = mFileNameFull(1:end-length(mFileName)); % Extract the dir of the mfile directory

if ~isempty(mFileDirMain)

    cd(mFileDirMain)    % change matlab current folder to mfile directory

end

clear mFileName mFileNameFull mFileDirMain              % clear variables

rng(0)                                                  % set the random seed to 0

if exist('OFDM_Class','class') == 8                     % Check if OFDM_Class exits

    OFDM_Class.checkForUpdatedVersion();                % Check if the class is updated

else

    fprintf('The OFDM_Class does not exist or its path is not added. You can download the class from this %s \n',...

        '<a href = "http://www.mathworks.com/matlabcentral/fileexchange/54070">Link</a>')

    return

end

%---------------------------------------------------------------------------------------------------

%                                            Main Part

%---------------------------------------------------------------------------------------------------

% Parameters

% First curve

Para1.NB                  = 5000;    % Number of ofdm symbols per run

Para1.I                   = 1;       % Number of iterations in each loop

Para1.M                   = 4;       % Modulation order (4 QPSK) it can be changed by user

Para1.N                   = 64;      % Number of sybcarriers

Para1.NFFT                = 64;      % Upsampling rate is 1, and FFT based interpolation is used

Para1.ifDoRaylieghChannel = 0;       % No Rayliegh channel

Para1.ifDoAWGNChannel     = 1;       % Only AWGN Channel

% Second curve

Para2 = Para1;                       % all parameters are the same as what defined in Para1 except the modulation order

Para2.M                   = 16;      % Modulation order (16 QAM) it can be changed by user

% Building class

Obj1 = OFDM_Class(Para1);

Obj2 = OFDM_Class(Para2);

% Loop Parameters

Loop.EbN0dB    = 0:10;

Loop.SNRdBVec1 = 10*log10(log2(Obj1.M))+Loop.EbN0dB;

Loop.SNRdBVec2 = 10*log10(log2(Obj2.M))+Loop.EbN0dB;

Loop.EbN0dBL = length(Loop.EbN0dB);

Loop.Results   = zeros(Loop.EbN0dBL,Obj1.I,8);

Loop.Cnt       = 0;

% Main Loop

fprintf('-------------------------------------\n')

for LoopCnt1 = 1 :  Loop.EbN0dBL

    % Update parameters

    Obj1.channSNRdB = Loop.SNRdBVec1(LoopCnt1);

    Obj2.channSNRdB = Loop.SNRdBVec2(LoopCnt1);

    for LoopCnt2 = 1 : Obj1.I

        % Transmitter

        Obj1.ofdmTransmitter();

        Obj2.ofdmTransmitter();

        % Channel

        Obj1.ofdmChannel();

        Obj2.ofdmChannel();

        % Receiver

        Obj1.ofdmReceiver();

        Obj2.ofdmReceiver();

        % BER calculation

        Obj1.ofdmBER();

        Obj2.ofdmBER();

        

        % Store the results for the first curve

        Loop.Results(LoopCnt1,LoopCnt2,1) = Obj1.BER;

        Loop.Results(LoopCnt1,LoopCnt2,2) = Obj1.DER;

        Loop.Results(LoopCnt1,LoopCnt2,3) = Obj1.BERTheoryAWGN;

        Loop.Results(LoopCnt1,LoopCnt2,4) = Obj1.EbN0dB;

        

        % Store the results for the second curve

        Loop.Results(LoopCnt1,LoopCnt2,5) = Obj2.BER;

        Loop.Results(LoopCnt1,LoopCnt2,6) = Obj2.DER;

        Loop.Results(LoopCnt1,LoopCnt2,7) = Obj2.BERTheoryAWGN;

        Loop.Results(LoopCnt1,LoopCnt2,8) = Obj2.EbN0dB;

        

        % Display

        Loop.Cnt = Loop.Cnt + 1;

        fprintf('%10.1f percent of the simulation is done.\n',Loop.Cnt*100/(Loop.EbN0dBL  * Obj1.I))

    end

end

fprintf('-------------------------------------\n')

% Plots

figure(1)

clf

semilogy(mean(Loop.Results(:,:,4),2), mean(Loop.Results(:,:,1),2),'bo:') % Simulation BER (first curve)

hold on

semilogy(mean(Loop.Results(:,:,4),2), mean(Loop.Results(:,:,3),2),'b-')  % Theory BER (first curve)

semilogy(mean(Loop.Results(:,:,8),2), mean(Loop.Results(:,:,5),2),'rs:') % Simulation BER (second curve)

semilogy(mean(Loop.Results(:,:,8),2), mean(Loop.Results(:,:,7),2),'r-')  % Theory BER (second curve)

grid on

xlabel('EbN0 [dB]')

ylabel('BER')

legend([Obj1.ModulationStr,'-Simulation'],[Obj1.ModulationStr,'-Theory'],...

    [Obj2.ModulationStr,'-Simulation'],[Obj2.ModulationStr,'-Theory'])

title('OFDM system performance over AWGN channel')

⛄ 运行结果

⛄ 参考文献

[1]任文超, 姜军. AWGN信道中一种改进OFDM系统信道估计算法[J].  2013.

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

❤️ 关注我领取海量matlab电子书和数学建模资料

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值