Matlab簡單的OFDM仿真信道估計有BER曲線備課講稿_第1頁
Matlab簡單的OFDM仿真信道估計有BER曲線備課講稿_第2頁
Matlab簡單的OFDM仿真信道估計有BER曲線備課講稿_第3頁
Matlab簡單的OFDM仿真信道估計有BER曲線備課講稿_第4頁
Matlab簡單的OFDM仿真信道估計有BER曲線備課講稿_第5頁
已閱讀5頁,還剩14頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、Good is good, but better carries it.精益求精,善益求善。Matlab簡單的OFDM仿真,信道估計,有BER曲線-clearall;closeall;fprintf(nOFDM仿真nn);%-%參數定義%-%IFFT_bin_length=1024;carrier_count=200;bits_per_symbol=2;symbols_per_carrier=50;%子載波數200%位數/符號2%符號數/載波50%訓練符號數10%循環(huán)前綴長度T/4(作者注明)All-zeroCP%調制方式QDPSK%多徑信道數2、3、4(缺?。?信道最大時延7(單位數據符號)

2、%仿真條件收發(fā)之間嚴格同步%SNR=input(SNR=);%輸入信噪比參數SNR=3:14;%定義信噪比范圍BER=zeros(1,length(SNR);baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;%計算發(fā)送的二進制序列長度carriers=(1:carrier_count)+(floor(IFFT_bin_length/4)-floor(carrier_count/2);%坐標:(1to200)+156,157-356conjugate_carriers=IFFT_bin_length-car

3、riers+2;%坐標:1024-(157:356)+2=1026-(157:356)=(869:670)%構造共軛時間載波矩陣,以便應用所謂的RCC,ReducedComputationalComplexity算法,即ifft之后結果為實數%Definetheconjugatetime-carriermatrix%也可以用flipdim函數構造對稱共軛矩陣%-%信號發(fā)射%-%out=rand(1,baseband_out_length);%baseband_out1=round(out);%baseband_out2=floor(out*2);%baseband_out3=ceil(out*

4、2)-1;%baseband_out4=randint(1,baseband_out_length);%四種生成發(fā)送的二進制序列的方法,任取一種產生要發(fā)送的二進制序列%if(baseband_out1=baseband_out2&baseband_out1=baseband_out3)%fprintf(TransmissionSequenceGeneratednn);%baseband_out=baseband_out1;%else%fprintf(CheckCode!nn);%end%驗證四種生成發(fā)送的二進制序列的方法baseband_out=round(rand(1,baseband_ou

5、t_length);convert_matrix=reshape(baseband_out,bits_per_symbol,length(baseband_out)/bits_per_symbol);fork=1length(baseband_out)/bits_per_symbol),modulo_baseband(k)=0;fori=1:bits_per_symbolmodulo_baseband(k)=modulo_baseband(k)+convert_matrix(i,k)*2(bits_per_symbol-i);endend%每2個比特轉化為整數0至3%采用left-msb方式%

6、-%Testbylavabin%Abuilt-infunctionofdirectlychangebinarybitsintodecimalnumbers%-%convert_matrix1=zeros(length(baseband_out)/bits_per_symbol,bits_per_symbol);%convert_matrix1=convert_matrix;%Test_convert_matrix1=bi2de(convert_matrix1,bits_per_symbol,left-msb);%Test_convert_matrix2=bi2de(convert_matrix

7、1,bits_per_symbol,right-msb);%函數說明:%BI2DEConvertbinaryvectorstodecimalnumbers.%D=BI2DE(B)convertsabinaryvectorBtoadecimalvalueD.WhenBis%amatrix,theconversionisperformedrow-wiseandtheoutputDisa%columnvectorofdecimalvalues.Thedefaultorientationofthebinary%inputisRight-MSB;thefirstelementinBrepresentst

8、heleastsignificantbit.%if(modulo_baseband=Test_convert_matrix1)%fprintf(modulo_baseband=Test_convert_matrix1nnn);%elseif(modulo_baseband=Test_convert_matrix2)%fprintf(modulo_baseband=Test_convert_matrix2nnn);%else%fprintf(modulo_baseband=anyTest_convert_matrixnnn);%end%end%wegettheresultmodulo_baseb

9、and=Test_convert_matrix1.%-carrier_matrix=reshape(modulo_baseband,carrier_count,symbols_per_carrier);%生成時間載波矩陣%-%QDPSK調制%-%carrier_matrix=zeros(1,carrier_count);carrier_matrix;%添加一個差分調制的初始相位,為0fori=2symbols_per_carrier+1)carrier_matrix(i,=rem(carrier_matrix(i,+carrier_matrix(i-1,2bits_per_symbol);%差

10、分調制endcarrier_matrix=carrier_matrix*(2*pi)/(2bits_per_symbol);%產生差分相位X,Y=pol2cart(carrier_matrix,ones(size(carrier_matrix,1),size(carrier_matrix,2);%由極坐標向復數坐標轉化第一參數為相位第二參數為幅度%Carrier_plex_carrier_matrix=complex(X,Y);%添加訓練序列training_symbols=1jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1.-j-j-

11、11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-1.1jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1.-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j.-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-11jj1-1-j-j-1;%25times1jj1,25times-1-j-j-1,totally200symbolsasarowtra

12、ining_symbols=cat(1,training_symbols,training_symbols);training_symbols=cat(1,training_symbols,training_symbols);%Productionof4rowsoftraining_symbolscomplex_carrier_matrix=cat(1,training_symbols,complex_carrier_matrix);%訓練序列與數據合并%block-typepilotsymbolsIFFT_modulation=zeros(4+symbols_per_carrier+1,IF

13、FT_bin_length);%Herearowvectorofzerosisbetweentrainingsymbolsanddatasymbols!%4trainingsymbolsand1zerosymbol%everyOFDMsymboltakesarowofIFFT_modulationIFFT_modulation(:,carriers)=complex_carrier_matrix;IFFT_modulation(:,conjugate_carriers)=conj(complex_carrier_matrix);%-%Testbylavabin-Findtheindicesof

14、zeros%index_of_zeros=zeros(symbols_per_carrier,IFFT_bin_length-2*carrier_count);%IFFT_modulation1=zeros(4+symbols_per_carrier+1,IFFT_bin_length);%IFFT_modulation2=zeros(4+symbols_per_carrier+1,IFFT_bin_length);%IFFT_modulation1(6:symbols_per_carrier+5,=IFFT_modulation(6:symbols_per_carrier+5,=0;%for

15、i=1:symbols_per_carrier%index_of_zeros(i,=find(IFFT_modulation1(i+5,=1);%end%-time_wave_matrix=ifft(IFFT_modulation);%進行IFFT操作time_wave_matrix=time_wave_matrix;%IfXisamatrix,ifftreturnstheinverseFouriertransformofeachcolumnofthematrix.fori=1:4+symbols_per_carrier+1windowed_time_wave_matrix(i,:)=real

16、(time_wave_matrix(i,:);end%gettherealpartoftheresultofIFFT%這一步可以省略,因為IFFT結果都是實數%由此可以看出,只是取了IFFT之后載波上的點,并未進行CP的復制和添加endofdm_modulation=reshape(windowed_time_wave_matrix,1,IFFT_bin_length*(4+symbols_per_carrier+1);%P2Soperation%-%Testbylavabin%Anotherwayofmatrixtransition%ofdm_modulation_tmp=windowed_

17、time_wave_matrix.;%ofdm_modulation_test=ofdm_modulation_tmp(;%if(ofdm_modulation_test=ofdm_modulation)%fprintf(ofdm_modulation_test=ofdm_modulationnnn);%else%fprintf(ofdm_modulation_test=ofdm_modulationnnn);%end%Wegettheresultofdm_modulation_test=ofdm_modulation.%-Tx_data=ofdm_modulation;%-%信道模擬%-%d

18、1=4;a1=0.2;d2=5;a2=0.3;d3=6;a3=0.4;d4=7;a4=0.5;%信道模擬copy1=zeros(size(Tx_data);fori=1+d1:length(Tx_data)copy1(i)=a1*Tx_data(i-d1);endcopy2=zeros(size(Tx_data);fori=1+d2:length(Tx_data)copy2(i)=a2*Tx_data(i-d2);endcopy3=zeros(size(Tx_data);fori=1+d3:length(Tx_data)copy3(i)=a3*Tx_data(i-d3);endcopy4=ze

19、ros(size(Tx_data);fori=1+d4:length(Tx_data)copy4(i)=a4*Tx_data(i-d4);endTx_data=Tx_data+copy1+copy2+copy3+copy4;%4multi-pathsTx_signal_power=var(Tx_data);foridx=1:length(SNR)%montecarlo仿真模擬linear_SNR=10(SNR(idx)/10);noise_sigma=Tx_signal_power/linear_SNR;noise_scale_factor=sqrt(noise_sigma);noise=ra

20、ndn(1,length(Tx_data)*noise_scale_factor;Rx_Data=Tx_data+noise;%-%信號接收%-%Rx_Data_matrix=reshape(Rx_Data,IFFT_bin_length,4+symbols_per_carrier+1);Rx_spectrum=fft(Rx_Data_matrix);%SupposeprecisesynchronazitionbetweenTxandRxRx_carriers=Rx_spectrum(carriers,:);Rx_training_symbols=Rx_carriers(1:4),:);Rx_

21、carriers=Rx_carriers(5:55),:);%-%信道估計%-%Rx_training_symbols=Rx_training_symbols./training_symbols;Rx_training_symbols_deno=Rx_training_symbols.2;Rx_training_symbols_deno=Rx_training_symbols_deno(1,+Rx_training_symbols_deno(2,+Rx_training_symbols_deno(3,+Rx_training_symbols_deno(4,;Rx_training_symbol

22、s_nume=Rx_training_symbols(1,:)+Rx_training_symbols(2,:)+Rx_training_symbols(3,:)+Rx_training_symbols(4,:);Rx_training_symbols_nume=conj(Rx_training_symbols_nume);%取4個向量的導頻符號是為了進行平均優(yōu)化%都是針對“行向量”即單個的OFDM符號進行操作%原理:尋求1/H,對FFT之后的數據進行頻域補償%1/H=conj(H)/H2becauseH2=H*conj(H)Rx_training_symbols=Rx_training_sy

23、mbols_nume./Rx_training_symbols_deno;Rx_training_symbols=Rx_training_symbols_nume./Rx_training_symbols_deno;Rx_training_symbols_2=cat(1,Rx_training_symbols,Rx_training_symbols);Rx_training_symbols_4=cat(1,Rx_training_symbols_2,Rx_training_symbols_2);Rx_training_symbols_8=cat(1,Rx_training_symbols_4,

24、Rx_training_symbols_4);Rx_training_symbols_16=cat(1,Rx_training_symbols_8,Rx_training_symbols_8);Rx_training_symbols_32=cat(1,Rx_training_symbols_16,Rx_training_symbols_16);Rx_training_symbols_48=cat(1,Rx_training_symbols_32,Rx_training_symbols_16);Rx_training_symbols_50=cat(1,Rx_training_symbols_48

25、,Rx_training_symbols_2);Rx_training_symbols=cat(1,Rx_training_symbols_50,Rx_training_symbols);Rx_carriers=Rx_training_symbols.*Rx_carriers;%進行頻域單抽頭均衡Rx_phase=angle(Rx_carriers)*(180/pi);phase_negative=find(Rx_phase0);%-TestofUsingrem-%Rx_phase1=Rx_phase;%Rx_phase2=Rx_phase;%Rx_phase1(phase_negative)

26、=rem(Rx_phase1(phase_negative)+360,360);%Rx_phase2(phase_negative)=Rx_phase2(phase_negative)+360;%ifRx_phase2(phase_negative)=Rx_phase1(phase_negative)%fprintf(nThereisnoneedusingreminnegativephasetransition.n)%else%fprintf(nWeneedtousereminnegativephasetransition.n)%end%-Rx_phase(phase_negative)=re

27、m(Rx_phase(phase_negative)+360,360);%把負的相位轉化為正的相位Rx_decoded_phase=diff(Rx_phase);%這也是為什么要在前面加上初始相位的原因%“Herearowvectorofzerosisbetweentrainingsymbolsanddatasymbols!”phase_negative=find(Rx_decoded_phase0);Rx_decoded_phase(phase_negative)=rem(Rx_decoded_phase(phase_negative)+360,360);%再次把負的相位轉化為正的相位%-%

28、QDPSK解調%-%base_phase=360/2bits_per_symbol;delta_phase=base_phase/2;Rx_decoded_symbols=zeros(size(Rx_decoded_phase,1),size(Rx_decoded_phase,2);fori=1:(2bits_per_symbol-1)center_phase=base_phase*i;plus_delta=center_phase+delta_phase;%Decisionthreshold1minus_delta=center_phase-delta_phase;%Decisionthreshold2decoded=find(Rx_decoded_phaseminus_d

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論