• 大小: 6KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: Matlab
  • 标签: matlab  ls  

资源简介

基于matlab的OFDM系统信估计仿真代码,包含LS算法和基本的DFT算法,有完整的注释!

资源截图

代码片段和文件信息

clear all;
close all;
fprintf(‘OFDM信道估计仿真\n\n‘);
carrier_count=64;%-----------载波数目
num_symbol=50;%--------------OFDM符号个数
Guard=8;%--------------------循环前缀
pilot_Inter=8;%--------------导频间隔
modulation_mode=16;%---------调制方式
SNR=[0:2:20];%-------------信噪比取值
NumLoop=15;%-----------------循环次数
num_bit_err=zeros(length(SNR)NumLoop);   %生成m*n的全零阵
num_bit_err_dft=zeros(length(SNR)NumLoop);
num_bit_err_ls=zeros(length(SNR)NumLoop);
MSE=zeros(length(SNR)NumLoop);
MSE1=zeros(length(SNR)NumLoop);
MSE2=zeros(length(SNR)NumLoop);
%%%%%%%%%%%%%%%%%%%%%%%主程序循环%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for c1=1:length(SNR)
    fprintf(‘\n\n\n仿真信噪比为%f\n\n‘SNR(c1));
    for num1=1:NumLoop
        %---------------产生发送的随机序列——————————————
        BitsLen=carrier_count*num_symbol;
        BitsTx=randint(1BitsLen);
        %---------------符号调制---------------------------------------
        Modulated_Sequence=qammod(BitsTxmodulation_mode);

%插入导频的位置与已调信号的频谱结构有关基本原则是在已调信号频谱中的零点插入导频
%且要求其附近的信号频谱分量尽量小,这样便于插入导频以及解调时易于滤除它
        %---------------导频格式---------------------------------------
        pilot_len=carrier_count;
        pilot_symbols=round(rand(1pilot_len));
        for i=1:pilot_len
            if pilot_symbols(1i)==0
                pilot_symbols(1i)=pilot_symbols(1i)-1;
            else
                pilot_symbols(1i)=pilot_symbols(1i);
            end
        end
% pilot_symbols = [1-1-111]
        pilot_symbols=pilot_symbols‘;
        %----------------计算导频和数据数目----------------------------
        num_pilot=ceil(num_symbol/pilot_Inter);  % 7
        if rem(num_symbolpilot_Inter)==0
            num_pilot=num_pilot+1;
        end
        num_data=num_symbol+num_pilot; % 57
        %----------------导频和数据位置计算----------------------------------
        pilot_Indx=zeros(1num_pilot);
        Data_Indx=zeros(1num_pilot*(pilot_Inter+1)); % 63
        for i=1:num_pilot-1
            pilot_Indx(1i)=(i-1)*(pilot_Inter+1)+1;
        end
        pilot_Indx(1num_pilot)=num_data; % [0 10 19 28 37 46 57]

        for j=0:num_pilot
            Data_Indx(1(1+j*pilot_Inter):(j+1)*pilot_Inter)=(2+j*(pilot_Inter+1)):((j+1)*(pilot_Inter+1));
        end
        Data_Indx=Data_Indx(11:num_symbol);
        %----------------导频插入-------------------------------------
        piloted_ofdm_syms=zeros(carrier_countnum_data);
        piloted_ofdm_syms(:Data_Indx)=reshape(Modulated_Sequencecarrier_countnum_symbol);   % 把调制序列放入载波上
        piloted_ofdm_syms(:pilot_Indx)=repmat(pilot_symbols1num_pilot);  % 在序列中插入导频
        %----------------IFFT变换———————————————————
        time_signal=sqrt(carrier_count)*ifft(piloted_ofdm_syms);
        %----------------加循环前缀------------------------------------
        add_cyclic_signal=[time_signal((carrier_count-Guard+1:carrier_count):);time_signal];
        Tx_data_trans=reshape(add_cyclic_signal1(carrier_count+Guard)*num_data);
        %-------------

评论

共有 条评论