channel.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:3k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- function recv_signal = channel( transmit_signal,h_time, ch, N_Tx_ant, N_Rx_ant ,...
- PreNoiseLen,PostNoiseLen, var_noise,N_subc,PrefixRatio,N_sym,...
- delta_fc,T_sample,FreqSyn,AddChFreq)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 多径多天线信道
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if ~AddChFreq
- len = length(transmit_signal) + max(ch.Delay_sample) + PreNoiseLen + PostNoiseLen;
- recv_signal = zeros(1,len,N_Rx_ant);
- tmp_recv = zeros(1,length(transmit_signal) + max(ch.Delay_sample),N_Rx_ant);
- % 对每条接收天线的信号, 是N_tx_ant个数据的叠加
- for n_r = 1:N_Rx_ant
- tmp_signal = zeros(1,length(transmit_signal) + max(ch.Delay_sample) );
- for n_t = 1:N_Tx_ant
- % 对单天线信道, 是N_path条径的延时叠加. h_time是时域信道的系数矩阵
- % 首先取一对天线,h_time(:,:,(n_t-1)*N_Tx_ant + n_r)是N_path行, N_sym列的矩阵
- % 把h_time扩展为每个OFDM符号有N_subc*(1 + PrefixRatio)个衰落系数
- % 乘上对应的时域样点.
- max_d = max(ch.Delay_sample);
- for p = 1:ch.N_path
- % 信道响应的使用:如4发2收天线,先取h_time的第1到第4行,作为第1~4发送天线,第1条接收天线
- % 的信道响应。然后取h_time的第5到第8行,作为第1~4发送天线,第2条接收天线的信道响应
- ch_coeff = h_time( p ,:, n_t + N_Tx_ant*(n_r - 1));
- ch_coeff = reshape( repmat(ch_coeff, N_subc*(1 + PrefixRatio),1) ,...
- 1,N_subc*(1 + PrefixRatio)*N_sym );
- delay = ch.Delay_sample(p);
- % 然后把N_path条路径延时叠加,得到长度为length(transmit_signal) + max(ch.Delay_sample)的向量
- tmp_signal = tmp_signal + ...
- [zeros(1, delay) transmit_signal(1,:,n_t).*ch_coeff zeros(1,max_d - delay)];
- end
- % 把不同发送天线的信号叠加
- tmp_recv(1,:,n_r) = tmp_recv(1,:,n_r) + tmp_signal;
- end
- end
- % 在每条接收天线的信号加噪声,并加前噪声和后噪声,用于定时同步算法
- recv_signal = [ zeros(1,PreNoiseLen,N_Rx_ant) tmp_recv zeros(1,PostNoiseLen,N_Rx_ant) ];
- noise = sqrt(var_noise)*( randn(1,len,N_Rx_ant) + j*randn(1,len,N_Rx_ant) );
- recv_signal = recv_signal + noise;
- % 加载波频偏
- if FreqSyn
- idx = repmat([0:length(recv_signal)-1],[1,1,N_Rx_ant]);
- recv_signal = recv_signal.*exp(j*2*pi*delta_fc*idx*T_sample);
- end
- % 加抽样频偏, 下一步完成
- else
- recv_signal = NaN;
- end