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

资源简介

OFDM中LS和DFT信道估计算法matlab程序实现及比较

资源截图

代码片段和文件信息

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);
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=pilot_symbols‘;
        %----------------计算导频和数据数目----------------------------
        num_pilot=ceil(num_symbol/pilot_Inter);
        if rem(num_symbolpilot_Inter)==0
            num_pilot=num_pilot+1;
        end
        num_data=num_symbol+num_pilot;
        %----------------导频位置计算----------------------------------
        pilot_Indx=zeros(1num_pilot);
        Data_Indx=zeros(1num_pilot*(pilot_Inter+1));
        for i=1:num_pilot-1
            pilot_Indx(1i)=(i-1)*(pilot_Inter+1)+1;
        end
        pilot_Indx(1num_pilot)=num_data;
        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);
        %----------------信道处理--------------------------------------
        Tx_signal_power=sum(abs(Tx_data_trans(:)).^2)/length(Tx_data_trans(:));
        noise_var=Tx_signal_power/(10^(SNR(c1)/10));
  

评论

共有 条评论