导频 matlab,v06_03_dem_2up_arrange.m 源代码在线查看 - 完美的OFDM仿真程序MATLAB(带导频),可直接运行 资源下载 虫虫电子下载站...
% 一個OFDM符號128個有效符號,插入128個虛擬子載波% 符號率(即有效數據率)fsymbol,而發送速率(需要包括虛擬子載波)2fsymbol% 輸入的數據需要2倍的發送數據率,以便進行內插,實現位定時跟蹤,即4倍fsymbol采樣率的調制信號% OFDM symbol Nfft=128 points% 一個OFDM符號數據點 Nfft*2 = 256 , Guard Interval點 =Ng*2=64% ------------------------------------------------------------------------------------close all;clear;initializing_now = ['please wait...']% ------------------------------------------------------------------------------------% 參數設置% 系統參數設置% FFT點數為256,子載波個數為128,虛擬子載波個數為128Nfft = 128;Ng = 32;Ntotal = Nfft+Ng;M_pilot = 8; % 每個OFDM符號加入的導頻數目Max_symbols = 50;% 讀取訓練字% 短訓練字的內容% 10重復的個短訓練字,每個是一個Guard Interval的長度% 可以看成2個重復的長訓練字,每個長訓練字是由5個重復的部分組成的% 這里讀入的是這樣一個假設的長訓練字的頻域上的值% I,Q兩路分別讀入fid3=fopen('data_I_train_word_re_i0_256.txt','r');I_train_word_re_temp=fscanf(fid3,'%f');fclose(fid3);I_train_word_re = (I_train_word_re_temp)';fid3=fopen('data_Q_train_word_re_i0_256.txt','r');Q_train_word_re_temp=fscanf(fid3,'%f');fclose(fid3);Q_train_word_re = (Q_train_word_re_temp)';train_word_re = I_train_word_re + j*Q_train_word_re;% 第一個訓練字的內容% 這里讀入的是第一個長訓練字的頻域上的值% I,Q兩路分別讀入fid3=fopen('data_I_train_word_1_i0_256.txt','r');I_train_word_1_temp=fscanf(fid3,'%f');fclose(fid3);I_train_word_1 = (I_train_word_1_temp)';fid3=fopen('data_Q_train_word_1_i0_256.txt','r');Q_train_word_1_temp=fscanf(fid3,'%f');fclose(fid3);Q_train_word_1 = (Q_train_word_1_temp)';train_word_1 = I_train_word_1 + j*Q_train_word_1;% 第二個訓練字的內容% 這里讀入的是第二個長訓練字的頻域上的值% I,Q兩路分別讀入fid3=fopen('data_I_train_word_2_i0_256.txt','r');I_train_word_2_temp=fscanf(fid3,'%f');fclose(fid3);I_train_word_2 = (I_train_word_2_temp)';fid3=fopen('data_Q_train_word_2_i0_256.txt','r');Q_train_word_2_temp=fscanf(fid3,'%f');fclose(fid3);Q_train_word_2 = (Q_train_word_2_temp)';train_word_2 = I_train_word_2 + j*Q_train_word_2;% 第二個長訓練字與第一個長訓練字對應子載波位置上的值的比值% 用于整數倍頻偏估計,具體算法參考Schmidl和Cox的文章% "Robust Frequency and Timing Synchronization for OFDM"for temp_i=1:1:Nfft/2 if(rem(temp_i,2)==1) vv(temp_i)=sqrt(2)*train_word_2(temp_i)/train_word_1(temp_i); endend% 緩沖區參數設置% 采用兩個緩沖區,當對一個緩沖區里的數據進行處理的時候,對另一個緩沖區進行數據寫入% 同一個緩沖區不同時進行讀和寫的操作% 軟件仿真這一個過程跟實際過程中的一個極端情況,可以應用于實際情況MI_IN_1(1:Ntotal*2*8) = 0;MQ_IN_1(1:Ntotal*2*8) = 0;MI_IN_2(1:Ntotal*2*8) = 0;MQ_IN_2(1:Ntotal*2*8) = 0; % 直接從已經準備好的文件里讀出來的數據的存儲空間 % 此時是完全理想的數據,沒有加任何噪聲以及偏移量 % I、Q是區分I、Q兩路信號 % 1、2是區分兩個交替使用的緩沖區I_INnoised_1(1:Ntotal*2*8) = 0;Q_INnoised_1(1:Ntotal*2*8) = 0;I_INnoised_2(1:Ntotal*2*8) = 0;Q_INnoised_2(1:Ntotal*2*8) = 0; % 加過高斯白噪聲后的數據的存儲空間 % I、Q是區分I、Q兩路信號 % 1、2是區分兩個交替使用的緩沖區I_INnoised_error_f_1(1:Ntotal*2*8) = 0;Q_INnoised_error_f_1(1:Ntotal*2*8) = 0;I_INnoised_error_f_2(1:Ntotal*2*8) = 0;Q_INnoised_error_f_2(1:Ntotal*2*8) = 0; % 加過載波頻偏后的數據的存儲空間 % I、Q是區分I、Q兩路信號 % 1、2是區分兩個交替使用的緩沖區IDEMOD_1(1:Ntotal*2*8) = 0;QDEMOD_1(1:Ntotal*2*8) = 0;IDEMOD_2(1:Ntotal*2*8) = 0;QDEMOD_2(1:Ntotal*2*8) = 0; % 最后實際進行處理的數據,已經仿真加入了噪聲以及偏移量 % I、Q是區分I、Q兩路信號 % 1、2是區分兩個交替使用的緩沖區% 內插濾波參數設置% 具體算法參考Floyd M. Gardner關于內插器的兩篇文章% "Interpolation in Digital Modems - Part I: Fundamentals"% "Interpolation in Digital Modems - Part II: Implementation and Performance"reg=0.9;wint=0.5000; % 內插器使輸出信號為輸入信號的1/2Ix(1:4)=0;Qx(1:4)=0; % 內插器參數設置alpha=0.5;B=[0,1,0,0; -alpha,alpha-1,alpha+1,-alpha; alpha,-alpha,-alpha,alpha]; % 內插器參數設置IV(1:3)=0;QV(1:3)=0; % 內插器參數設置IInter(1:Ntotal*2)=0;QInter(1:Ntotal*2)=0;c(1:Ntotal*2)=0; IInter_2(1:Ntotal*2*2)=0;QInter_2(1:Ntotal*2*2)=0;c_2(1:Ntotal*2*2)=0; % 經過內插后的數據的緩沖區設置 % 為2個OFDM符號長度 % 緩沖區c_2是循環使用,當數據填到最后一個位置后,重新從第一個位置填起k3 = 1; % 經過內插后的數據的緩沖區的下標位置指示k3_total = 0;% 定時同步參數設置Times_short_should_find = 4;short_tr_timed = 0;short_tr_detected = 0;t_short = 1;symbol_timed = 0;long_tr_detected = 0;t_long = 1;flag_long_index = 0;% 頻偏估計參數設置Timining_theory = 960;train_1_received(1:Nfft*2)=0;train_2_received(1:Nfft*2)=0;train_1_correct(1:Nfft*2)=0;train_2_correct(1:Nfft*2)=0;train_1_fft(1:Nfft*2)=0;train_2_fft(1:Nfft*2)=0;train_2_correct_full(1:Nfft*2)=0;phase_offset_1 = 0; % 小數倍頻偏phase_offset_2 = 0; % 整數倍頻偏% 信道估計參數設置phase_channel_current(1:Max_symbols,1:2*Nfft)=0;phase_channel(1:Max_symbols,1:2*Nfft)=0; % 信道相位響應Ap_channel_current(1:Max_symbols,1:2*Nfft)=1;Ap_channel(1:Max_symbols,1:2*Nfft)=1;% 信道幅度響應% 進行解調時FFT運算的參數設置t = 1;FFTin_temp(1:Nfft*2)=0;FFTin(1:Nfft*2)=0;FFTout_temp(1:Max_symbols,1:2*Nfft)=0;FFTout_ch_dis(1:Max_symbols,1:2*Nfft)=0;FFTout(1:Max_symbols,1:2*Nfft)=0;% 定時跟蹤參數設置% 定時跟蹤采樣雙環路跟蹤sita_tracking(1:Max_symbols)=0; sita(1:Max_symbols)=0; pilot_estimated(1:Max_symbols,1:M_pilot)=0;pilot_value=3*sqrt(2)*(cos(pi)+j*sin(pi));wn=0.05; % 定時跟蹤的環路帶寬1Wwn=0.000001; % 定時跟蹤的環路帶寬2Ss=0.7;f=1;G1=2*wn*Ss;G2=wn.^2/f;WG1=2*Wwn*Ss;WG2=Wwn.^2/f;Ks=1;et(1:Max_symbols)=0;ett(1:Max_symbols)=0;wt(1:Max_symbols)=0;Wwt(1:Max_symbols)=0;% 信道響應跟蹤參數設置wnp=0.3; % 信道相位響應跟蹤的環路帶寬Ssp=0.7;fp=1;G1p=2*wnp*Ssp;G2p=wnp.^2/fp;Ksp=1;
總結
以上是生活随笔為你收集整理的导频 matlab,v06_03_dem_2up_arrange.m 源代码在线查看 - 完美的OFDM仿真程序MATLAB(带导频),可直接运行 资源下载 虫虫电子下载站...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python数据分析实训大纲,数据分析大
- 下一篇: oh oh oh开头是哪首歌啊?