framing.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:3k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- function [transmit_signal, syn_preamble] = framing(input_signal,N_syn_preamble,PrefixRatio,N_subc,N_used,...
- Idx_used,N_Tx_ant,AddChFreq)
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 加N_syn_preamble个OFDM符号的同步序列,其结构(三个OFDM符号)如下:
- % 第1个OFDM符号在时域上重复Repeat次,第2个OFDM符号和第三个符号为相同的OFDM符号,所有子载波上均传数据
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- if ~AddChFreq
- % 为返回变量预先定义存储空间
- transmit_signal = zeros( 1,length(input_signal) + N_syn_preamble*N_subc*(1 + PrefixRatio),N_Tx_ant );
- syn_preamble = zeros( 1, N_syn_preamble*N_subc*(1 + PrefixRatio) , N_Tx_ant );
- % 产生伪随机序列,放在训练OFDM符号的导频位置.
- PN_seq = mseq(12, [1 3 5 9 ], [zeros(1,5) ones(1,7)], N_Tx_ant*N_syn_preamble); % 参数先随意选取,可以调整
- PN_seq = 2*PN_seq - 1;
- % 同步前导的频域信号
- syn_preamble_freq = zeros(N_subc,N_syn_preamble,N_Tx_ant);
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 1)产生1行,N_syn_preamble*N_subc*(1 + PrefixRatio)个样点的时域同步前导序列syn_preamble
- % 产生第1个训练OFDM符号
- Repeat = 2;
- for ant = 1:N_Tx_ant
- real_part = PN_seq( (ant-1)*2 + 1,1:N_used/Repeat ); % 截取PN序列
- imag_part = PN_seq( (ant-1)*2 + 2,1:N_used/Repeat );
- tran_tmp1 = sqrt(Repeat/2) * ( real_part + j * imag_part );
- tmp1 = [ tran_tmp1 ; zeros( Repeat - 1 , N_used/Repeat ) ];
- tmp2 = reshape(tmp1, N_used, 1);
- tmp3 = [ tmp2(1:N_used/2) ; flipud(tmp2(N_used/2 + 1:end))];
- syn_preamble_freq(Idx_used,1,ant) = tmp3;
- end
- % 产生第2,3个训练符号
- for ant = 1:N_Tx_ant
- % 相同天线的第2,3个训练符号内容相同
- syn_preamble_freq(Idx_used,2,ant) = PN_seq( N_Tx_ant + ant ,1:N_used );
- syn_preamble_freq(Idx_used,3,ant) = PN_seq( N_Tx_ant + ant ,1:N_used );
- end
- % 把同步训练序列变换到时域
- syn_frame = sqrt(N_subc) * ifft( fftshift( syn_preamble_freq , 1 ) );
- cp = syn_frame(N_subc - N_subc*PrefixRatio + 1:N_subc ,:,:);
- syn_preamble = [cp;syn_frame];
- syn_preamble = reshape(syn_preamble, [1,( N_subc + N_subc*PrefixRatio ) * N_syn_preamble ,N_Tx_ant] );
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 2)和数据时隙合并,组成发送到信道上的基带信号序列
- transmit_signal = [ syn_preamble input_signal];
- else
- transmit_signal = NaN;
- syn_preamble = NaN;
- end