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

更新时间:2024-05-03 21:50:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

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(1,BitsLen);

%---------------符号调制--------------------------------------- Modulated_Sequence=qammod(BitsTx,modulation_mode); %---------------导频格式--------------------------------------- pilot_len=carrier_count;

pilot_symbols=round(rand(1,pilot_len)); for i=1:pilot_len

if pilot_symbols(1,i)==0

pilot_symbols(1,i)=pilot_symbols(1,i)-1; else

pilot_symbols(1,i)=pilot_symbols(1,i); end end

pilot_symbols=pilot_symbols';

%----------------计算导频和数据数目---------------------------- num_pilot=ceil(num_symbol/pilot_Inter); if rem(num_symbol,pilot_Inter)==0 num_pilot=num_pilot+1; end

num_data=num_symbol+num_pilot;

%----------------导频位置计算----------------------------------

pilot_Indx=zeros(1,num_pilot);

Data_Indx=zeros(1,num_pilot*(pilot_Inter+1)); for i=1:num_pilot-1

pilot_Indx(1,i)=(i-1)*(pilot_Inter+1)+1; end

pilot_Indx(1,num_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(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; for ii=1:carrier_count

channel_H_ls(ii,:)=interp1(int_len,pilot_esti(ii,1:(num_pilot)),len,'linear'); end

channel_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; for ii=1:carrier_count

channel_H_dft(ii,:)=interp1(int_len,Tx_pilot_estimate_dft(ii,1:(num_pilot)),len,'linear'); end

channel_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); %----------------误码率的计算---------------------------------- for i=1:length(BitsTx)

if demod_out_dft(i)~=BitsTx(i)

num_bit_err_dft(c1,num1)=num_bit_err_dft(c1,num1)+1; end

if demod_out_ls(i)~=BitsTx(i)

num_bit_err_ls(c1,num1)=num_bit_err_ls(c1,num1)+1; end end end end

BER_dft=mean(num_bit_err_dft.')/length(BitsTx); BER_ls=mean(num_bit_err_ls.')/length(BitsTx);

%%%%%%%%%%%%%%%%%%%a%%%%%%%%主程序循环换结束%%%%%%%%%%%%%%%%%%%%%%%%%%%% figure

semilogy(SNR,BER_dft,'-mp',SNR,BER_ls,'-k+'); title('OFDM系统的LS和DFT信道估计'); xlabel('SNR'),ylabel('BER')

legend('LS信道估计','DFT信道估计');

本文来源:https://www.bwwdw.com/article/2qig.html

Top