沈阳航空航天大学电子信息工程学院毕业设计(论文)
end
end
%空时编码结束
XX=[tx_training_symbols;XX]; %添加训练序列
rx_buf=zeros(1,addprefix_length*(co_time+1),Nr); for rev=1:Nr for ii=1:Nt
tx_buf=reshape(XX(:,ii),carrier_count,co_time+1);
IFFT_tx_buf=zeros(IFFT_bin_length,co_time+1); %进行OFDM调制
IFFT_tx_buf(carriers,:)=tx_buf(1:carrier_count,:);
IFFT_tx_buf(conjugate_carriers,:)=conj(tx_buf(1:carrier_count,:)); time_matrix=ifft(IFFT_tx_buf);
time_matrix=[time_matrix((IFFT_bin_length-cp_length+1):IFFT_bin_length,:);time_matrix]; tx=time_matrix(:)';
%------------------------------------------------------------------------ %d=randint(1,4,[1,7]); %a=randint(1,4,[2,7])/10;
tx_tmp=tx;
% d=[4,5,6,2;4,5,6,2;4,5,6,2;4,5,6,2]; %4条径的瑞利信道 d为延时,a为多径衰落系数
d=[12,15,14,11;12,15,14,11;12,15,14,11;12,15,14,11;];
a=[0.6,0.3,0.4,0.5;0.6,0.3,0.4,0.5;0.6,0.3,0.4,0.5;0.6,0.3,0.4,0.5]; for jj=1:size(d,2) copy=zeros(size(tx)) ; for kk = 1 + d(ii,jj): length(tx)
- 36 -
沈阳航空航天大学电子信息工程学院毕业设计(论文)
copy(kk) = a(ii,jj)*tx(kk - d(ii,jj)) ; end
tx_tmp=tx_tmp+copy; end
%------------------------------------------------------------------------ if rayleigh_choice ==1 tx_tmp_rayleigh = tx_tmp; else
tx_tmp_rayleigh = tx; end
if gaussnoise_choice ==1
txch=awgn(tx_tmp_rayleigh,SNR,'measured'); 白噪声 else
txch = tx_tmp_rayleigh; end
rx_buf(1,:,rev)=rx_buf(1,:,rev)+txch; end
rx_spectrum=reshape(rx_buf(1,:,rev),addprefix_length,co_time+1); rx_spectrum=rx_spectrum(cp_length+1:addprefix_length,:); FFT_tx_buf=zeros(IFFT_bin_length,co_time+1); FFT_tx_buf=fft(rx_spectrum);
spectrum_matrix=FFT_tx_buf(carriers,:); Y_buf=(spectrum_matrix(:,2:co_time+1)); Y_buf=conj(Y_buf');
spectrum_matrix1=spectrum_matrix(:,1); Wk=exp((-2*pi/carrier_count)*i); L=10;
p=zeros(L*Nt,1); 对OFDM进行解调处理 for jj=1:Nt for l=0:L-1
%添加高斯 %去掉循环前缀 %以下为- 37 -
沈阳航空航天大学电子信息工程学院毕业设计(论文)
for kk=0:carrier_count-1
p(l+(jj-1)*L+1,1)=p(l+(jj-1)*L+1,1)+spectrum_matrix1(kk+1,1)*conj(tx_training_symbols(kk+1,jj))*Wk^(-(kk*l)); end end end
h=p/carrier_count;
H_buf=zeros(carrier_count,Nt); for ii=1:Nt
for kk=0:carrier_count-1 for l=0:L-1
H_buf(kk+1,ii)=H_buf(kk+1,ii)+h(l+(ii-1)*L+1,1)*Wk^(kk*l); end end end
H_buf=conj(H_buf');
RRR=[];
for kk=1:carrier_count %以下为解STBC编码 Y=Y_buf(:,kk); H=H_buf(:,kk); for co_ii=1:num_X for co_tt=1:size(eta,2) if eta(co_ii,co_tt)~=0
if coj_mt(eta(co_ii,co_tt),co_ii)==0
r_til(eta(co_ii,co_tt),:,co_ii)=Y(eta(co_ii,co_tt),:);
a_til(eta(co_ii,co_tt),:,co_ii)=conj(H(epsilon(eta(co_ii,co_tt),co_ii),:)); else
r_til(eta(co_ii,co_tt),:,co_ii)=conj(Y(eta(co_ii,co_tt),:)); a_til(eta(co_ii,co_tt),:,co_ii)=H(epsilon(eta(co_ii,co_tt),co_ii),:);
- 38 -
沈阳航空航天大学电子信息工程学院毕业设计(论文)
end end end end
RR=zeros(num_X,1); for
iii=1:num_X %对接收信号进行判决 for ttt=1:size(eta,2) if eta(iii,ttt)~=0
RR(iii,1)=RR(iii,1)+r_til(eta(iii,ttt),1,iii)*a_til(eta(iii,ttt),1,iii)*delta(eta(iii,ttt),iii); end end end
RRR=[RRR;conj(RR')]; end
r_sym=pskdemod(RRR,M_psk,0); re_met_sym_buf(:,tt:tt+Nt-1,rev)=r_sym; end end
re_met_sym=zeros(baseband_out_length,1,Nr);
for rev=1:Nr
re_met_sym_buf_buf=re_met_sym_buf(:,:,rev); re_met_sym(:,1,rev)= re_met_sym_buf_buf(:);
re_met_bit(:,:,rev)=de2bi(re_met_sym(:,1,rev)); %十进制转换为二进制
for con_dec_ro=1:baseband_out_length %以下为统计误码率和误比特率
if re_met_sym(con_dec_ro,1,rev)~=de_data(con_dec_ro,1)
- 39 -
沈阳航空航天大学电子信息工程学院毕业设计(论文)
n_err_sym(1,rev)=n_err_sym(1,rev)+1; for con_dec_co=1:bits_per_symbol if
re_met_bit(con_dec_ro,con_dec_co,rev)~=baseband_out(con_dec_ro,con_dec_co) n_err_bit(1,rev)=n_err_bit(1,rev)+1; end end end end
graph_inf_sym(SNR-snr_min+1,1,rev)=SNR; graph_inf_bit(SNR-snr_min+1,1,rev)=SNR;
Perr_sym(1,rev)=n_err_sym(1,rev)/(baseband_out_length); graph_inf_sym(SNR-snr_min+1,2,rev)=Perr_sym(1,rev);
Perr_bit(1,rev)=n_err_bit(1,rev)/(baseband_out_length*bits_per_symbol); graph_inf_bit(SNR-snr_min+1,2,rev)=Perr_bit(1,rev); end end
[vblast_ber0,vblast_ber1,vblast_ber2,vblast_ber3,vblast_ber4]=vblast(SNRin); figure(1); for rev=1:rev
x_sym=graph_inf_sym(:,1,rev); %画出误码率的曲线图 y_sym=graph_inf_sym(:,2,rev); subplot(Nr,1,rev);
semilogy(x_sym,y_sym,'k-v'); %axis([2 16 0.0001 1]); xlabel('SNR, [dB]');
ylabel('Symbol Error Probability'); grid on %hold on end
- 40 -