基于导频的ofdm系统的信道估计程序

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

clearall;closeall;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);%%%%%%%%%%%%%%%%%%%%%%%主程序循环%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%forc1=1:length(SNR)fprintf('\n\n\n仿真信噪比为%f\n\n',SNR(c1));fornum1=1:NumLoop%---------------产生发送的随机序列——————————————-BitsLen=carrier_count*num_symbol;BitsTx=randint(1,BitsLen);%---------------符号调制---------------------------------------Modulated_Sequence=qammod(BitsTx,modulation_mode);%---------------导频格式---------------------------------------pilot_len=carrier_count;pilot_symbols=round(rand(1,pilot_len));fori=1:pilot_lenifpilot_symbols(1,i)==0pilot_symbols(1,i)=pilot_symbols(1,i)-1;elsepilot_symbols(1,i)=pilot_symbols(1,i);endendpilot_symbols=pilot_symbols';%----------------计算导频和数据数目----------------------------num_pilot=ceil(num_symbol/pilot_Inter);ifrem(num_symbol,pilot_Inter)==0num_pilot=num_pilot+1;endnum_data=num_symbol+num_pilot;%----------------导频位置计算----------------------------------pilot_Indx=zeros(1,num_pilot);Data_Indx=zeros(1,num_pilot*(pilot_Inter+1));fori=1:num_pilot-1pilot_Indx(1,i)=(i-1)*(pilot_Inter+1)+1;endpilot_Indx(1,num_pilot)=num_data;forj=0:num_pilotData_Indx(1,(1+j*pilot_Inter):(j+1)*pilot_Inter)=(2+j*(pilot_Inter+1)):((j+1)*(pilot_Inter+1));endData_Indx=Data_Indx(1,1:num_symbol);%----------------导频插入-------------------------------------piloted_ofdm_syms=zeros(carrier_count,num_data);piloted_ofdm_syms(:,Data_Indx)=reshape(Modulated_Sequence,carrier_count,num_symbol);piloted_ofdm_syms(:,pilot_Indx)=repmat(pilot_symbols,1,num_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_signal,1,(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));Rx_data=awgn(Tx_data_trans,SNR(c1),'measured');%----------------信号接收、去循环前缀、FFT变换-----------------Rx_signal=reshape(Rx_data,(carrier_count+Guard),num_data);Rx_signal_matrix=zeros(carrier_count,num_data);Rx_signal_matrix=Rx_signal(Guard+1:end,:);Rx_carriers=fft(Rx_signal_matrix)/sqrt(carrier_count);%----------------导频和数据提取--------------------------------Rx_pilot=Rx_carriers(:,pilot_Indx);Rx_fre_data=Rx_carriers(:,Data_Indx);%----------------导频位置信道响应LS估计------------------------pilot_patt=repmat(pilot_symbols,1,num_pilot);pilot_esti=Rx_pilot./pilot_patt;%----------------LS估计的线性插值———————————————int_len=pilot_Indx;len=1:num_data;forii=1:carrier_countchannel_H_ls(ii,:)=interp1(int_len,pilot_esti(ii,1:(num_pilot)),len,'linear');endchannel_H_data_ls=channel_H_ls(:,Data_Indx);%----------------LS估计中发送数据的估计值----------------------Tx_data_estimate_ls=Rx_fre_data.*conj(channel_H_data_ls)./(abs(channel_H_data_ls).^2);%----------------DFT估计--------------------------------------Tx_pilot_estimate_ifft=ifft(pilot_esti);padding_zero=zeros(1024,7);Tx_pilot_estimate_ifft_padding_zero=[Tx_pilot_estimate_ifft;padding_zero];Tx_pilot_estimate_dft=fft(Tx_pilot_estimate_ifft_padding_zero);%----------------DFT估计的线性插值———————————————int_len=pilot_Indx;len=1:num_data;forii=1:carrier_countchannel_H_dft(ii,:)=interp1(int_len,Tx_pilot_estimate_dft(ii,1:(num_pilot)),len,'linear');endchannel_H_data_dft=channel_H_dft(:,Data_Indx);%----------------DFT估计中发送数据的估计值----------------------Tx_data_estimate_dft=Rx_fre_data.*conj(channel_H_data_dft)./(abs(channel_H_data_dft).^2);%----------------DFT符号解调------------------------------------demod_in_dft=Tx_data_estimate_dft(:).';demod_out_dft=qamdemod(demod_in_dft,modulation_mode);%----------------LS符号解调------------------------------------demod_in_ls=Tx_data_estimate_ls(:).';demod_out_ls=qamdemod(demod_in_ls,modulation_mode);%----------------误码率的计算----------------------------------fori=1:length(BitsTx)ifdemod_out_dft(i)~=BitsTx(i)num_bit_err_dft(c1,num1)=num_bit_err_dft(c1,num1)+1;endifdemod_out_ls(i)~=BitsTx(i)num_bit_err_ls(c1,num1)=num_bit_err_ls(c1,num1)+1;endendendendBER_dft=mean(num_bit_err_dft.')/length(BitsTx);BER_ls=mean(num_bit_err_ls.')/length(BitsTx);%%%%%%%%%%%%%%%%%%%a%%%%%%%%主程序循环换结束%%%%%%%%%%%%%%%%%%%%%%%%%%%%figuresemilogy(SNR,BER_dft,'-mp',SNR,BER_ls,'-k+');title('OFDM系统的LS和DFT信道估计');xlabel('SNR'),ylabel('BER')legend('LS信道估计','DFT信道估计');

1 / 4
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功