channel_estimator.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:10k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- function [H_data , mse] = channel_estimator( pilot_sym,known_pilot,SISO_CE_Method,MIMO_CE_Method,...
- L_delay,InterpMethod,H_freq,N_Tx_ant,N_Rx_ant,N_subc,N_used,Idx_used,Modulation,var_noise,...
- ch,N_ts,N_sym_ts,N_pilot_sym_ts,N_data_sym_ts,Pos_pilot_sym,Pos_data_sym,N_syn_preamble,...
- frame,Idx_cir,TurnOn ,ChannelEffectTest,SwitchOrthogonalPilot);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 准备实现的信道估计算法
- % 一. 单天线信道估计算法,使用导频辅助进行信道估计
- % 1 - 基本LS算法; 2 - LS的DFT改进算法; 3 - 加判决反馈的LS-DFT
- % 4 - 基本MMSE算法; 5 - MMSE的DFT改进算法; 6 - 加判决反馈的MMSE-DFT
- % 7 - SVD分解算法,8 - Robust算法
- % 9 - 自适应滤波器结合单天线信道估计的方法, 10 - EM 方法
- % 插值方法: 1 - 线性插值, 2 - 二次插值, 3 - 三次样条插值,
- % 4 - 时域插值, 5 - 低通滤波器插值
- % 二. 多天线信道估计方法,使用导频辅助进行信道估计
- % 1 - 基本LS算法; 2 - LS的改进算法1; 3 - LS的改进算法2; 4 - LS的改进算法3;
- % 5 - 频域区分子载波的方法,使用 SISO_CE_Method 选择的算法,以及 InterpMethod 选择的插值方法
- % 6 - 发送多个OFDM符号,线性组合求得多天线信道响应
- % 三. 理想信道估计: 所有导频位置和数据符号位置的信道为已知的。
- % 四. 有关信道估计MSE的定义:估计的信道响应和理想响应的差的平方,并平均到每个子载波。
- % 文献上给出的MSE,一般定义如下:
- % 1) 第1类方法:估计导频位置的信道响应 + 频域和时域插值的方法,MSE定义为信道估计部分的MSE,不包括插值
- % 2) 第2类方法:迭代进行估计,如判决反馈,LMS自适应滤波等,MSE定义为全部估计迭代出的信道响应的MSE
- % 在863项目仿真中,MSE应该统一,否则不能比较不同算法总体的性能。
- % 定义为:本帧所有导频和数据OFDM符号处,估计的信道响应和理想信道响应的MSE
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 输出为数据时隙的信道响应
- H_data = zeros( N_subc, N_data_sym_ts*N_ts ,N_Tx_ant*N_Rx_ant );
- Pos_data = zeros( 1,N_data_sym_ts*N_ts );
- Pos_pilot = zeros( 1,N_pilot_sym_ts*N_ts );
- for ts = 1:N_ts
- Pos_data(1,(ts-1)*N_data_sym_ts + 1:ts*N_data_sym_ts) = Pos_data_sym + (ts-1)*N_sym_ts;
- Pos_pilot(1,(ts-1)*N_pilot_sym_ts + 1:ts*N_pilot_sym_ts) = Pos_pilot_sym + (ts-1)*N_sym_ts;
- end
- global h_t;
- if ( TurnOn & (ChannelEffectTest ~= 2) )
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %一. 单天线信道估计
- if N_Tx_ant == 1
- for n_r = 1:N_Rx_ant
- if SISO_CE_Method == (1 | 2)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 1.1 使用LS,LS-DFT, MMSE, SVD分解方法
- % 先估计出导频点位置的值 H_pilot
- H_ideal = H_freq(Idx_used,N_syn_preamble + Pos_pilot,n_r); % 理想的信道响应
- % 进行LS-DFT改进的估计
- H_pilot = estimator_ls( pilot_sym(:,:,n_r) , known_pilot , 2 , L_delay , H_ideal ,Idx_cir);
- % 再进行插值,得到整个帧的信道估计 H_frame
- H_frame(:,:,n_r) = ( interp1(Pos_pilot',H_pilot.',[1:N_ts*N_sym_ts]','linear') ).';
- % 得到数据时隙的信道响应 H_data
- H_data(:,:,n_r) = H_frame(:,Pos_data,n_r);
- elseif SISO_CE_Method == 9
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 1.2 使用自适应滤波方法,DD,Robust,迭代方法
- % LS信道估计值,帧结构参数,最强径检测参数
- ReceivedChannelData = estimator_ls( pilot_sym(:,:,n_r) , known_pilot );
- FrameStruct = struct('N_ts',N_ts,'N_sym_ts',N_sym_ts,'Pos',Pos_pilot_sym,'fd',ch.fd);
- % 得到整个帧的频域信道响应
- H_frame(:,:,n_r) = LMS2DChannelEstimationAlgorithm(ReceivedChannelData,...
- FrameStruct,Idx_cir);
- H_data(:,:,n_r) = H_frame(:,Pos_data,n_r);
- end
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 二. 多天线信道估计
- else
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 2.1 使用联合求解的多天线LS估计方法:
- if MIMO_CE_Method == ( 1 | 2 | 3 | 4)
- % 得到导频位置的信道响应 H_pilot
- % 使用多天线的LS估计方法
- K = N_subc;
- K0 = L_delay;
- H_p = zeros(N_subc,N_pilot_sym_ts*N_ts,N_Rx_ant*N_Tx_ant);
- for ts = 1:N_ts
- for p = 1:N_pilot_sym_ts
- % 接收到的频域导频样点
- pilot_rx = pilot_sym(:,(ts-1)*N_pilot_sym_ts + p,:);
- % 发送的频域导频样点
- pilot_tx = known_pilot(:,(ts-1)*N_pilot_sym_ts + p,:);
- % 进行多天线LS估计,得到不同发送天线,本时隙,所有导频位置的信道相应
- H_tmp = estimator_ls_txdiv(K,K0,N_Tx_ant,N_Rx_ant,pilot_rx,pilot_tx,frame,ts,p,var_noise,0,N_pilot_sym_ts);
- H_pilot(:,(ts-1)*N_pilot_sym_ts + p,:) = H_tmp;
- end
- end
- % 再进行插值,得到整个帧的信道估计 H_frame
- for nr = 1:N_Rx_ant
- for nt = 1:N_Tx_ant
- H_frame(:,:,(nr-1)*N_Tx_ant+nt) = ( interp1(Pos_pilot',H_pilot(:,:,(nr-1)*N_Tx_ant+nt).',...
- [1:N_ts*N_sym_ts]','linear') ).';
- end
- end
- % 输出数据OFDM的信道响应 H_data
- H_data = H_frame(:,Pos_data,:);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 2.2 使用频域区分子载波的方法:
- elseif MIMO_CE_Method == 5
- % 对每一条接收天线
- for n_r = 1:N_Rx_ant
- % 有多条发送天线
- for n_t = 1:N_Tx_ant
- Idx_tx = [n_t:N_Tx_ant:N_used];
- % 每条发送天线使用不同的子载波组,进行单天线的信道估计
- pilot_tx = known_pilot(Idx_tx,:,n_t);
- pilot_rx = pilot_sym(Idx_tx,:,n_r);
- H_ideal = H_freq(Idx_tx,N_syn_preamble + Pos_pilot,(n_r-1)*N_Tx_ant + n_t);
- if SISO_CE_Method == 1
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- H_pilot = estimator_ls( pilot_rx , pilot_tx , 2 ,L_delay , H_ideal ,Idx_cir );
- % 频域插值,得到所有子载波位置的信道响应
- H_interp = interp1( Idx_tx, H_pilot ,[1:N_used] ,'linear','extrap');
- % 时域插值,得到整个帧所有OFDM符号的信道响应
- H_frame(:,:,(n_r-1)*N_Tx_ant + n_t) = ...
- ( interp1(Pos_pilot',H_interp.',[1:N_ts*N_sym_ts]','linear') ).';
- elseif SISO_CE_Method == 9
- % LS信道估计值,帧结构参数
- ReceivedChannelData = estimator_ls( pilot_rx , pilot_tx );
- FrameStruct = struct('N_ts',N_ts,'N_sym_ts',N_sym_ts,'Pos',Pos_pilot_sym,'fd',ch.fd);
- % 得到整个帧所有OFDM符号的频域信道响应
- H_tmp = LMS2DChannelEstimationAlgorithm(ReceivedChannelData,...
- FrameStruct,Idx_cir);
- % 频域插值,得到所有子载波的信道响应
- H_frame(:,:,(n_r-1)*N_Tx_ant + n_t) = interp1( Idx_tx', H_tmp ,[1:N_used]' ,'spline','extrap');
- % ChannelParameter = struct('SubCarrierNumber',N_subc,'TxAntennaNumber',n_t);
- % H_frame(:,:,(n_r-1)*N_Tx_ant + n_t) = LMS2D( ReceivedChannelData, ...
- % FrameStruct, ChannelParameter, Idx_cir );
- end
- end
- end
- % 得到数据OFDM符号的信道响应
- H_data = H_frame(:,Pos_data,:);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 2.3 使用发送多个OFDM符号,线性组合求得多天线信道响应的方法:
- elseif MIMO_CE_Method == 6
- [H_data,H_frame]=estimator_linear_comb(pilot_sym,known_pilot,Idx_cir,...
- N_Rx_ant,N_Tx_ant,Pos_pilot,N_ts,N_sym_ts,Pos_data, Pos_pilot_sym,N_subc,N_data_sym_ts,...
- L_delay,SwitchOrthogonalPilot);
- end
- end
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 求信道估计的均方误差
- H_frame_ideal = H_freq(:,1 + N_syn_preamble : N_sym_ts*N_ts + N_syn_preamble ,:);
- diff = H_frame_ideal - H_frame;
- mse = sum(sum(sum( abs( diff ).^2 ) )) / ( N_subc*N_ts*N_sym_ts*N_Tx_ant*N_Rx_ant);
- mse_sym = sum(abs(diff).^2)/(N_subc);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 三. 理想信道估计
- else
- % 取出数据OFDM符号对应的理想信道估计
- H_data = zeros( N_subc, N_data_sym_ts*N_ts ,N_Tx_ant*N_Rx_ant );
- H_data = H_freq(:,Pos_data + N_syn_preamble ,:);
- mse = 0;
- end