Matlab简单的OFDM仿真-信道估计-有BER曲线

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

clearall;closeall;fprintf('\nOFDM仿真\n\n');%---------------------------------------------%%参数定义%%---------------------------------------------%IFFT_bin_length=1024;carrier_count=200;bits_per_symbol=2;symbols_per_carrier=50;%子载波数200%位数/符号2%符号数/载波50%训练符号数10%循环前缀长度T/4(作者注明)All-zeroCP%调制方式QDPSK%多径信道数2、3、4(缺省)%信道最大时延7(单位数据符号)%仿真条件收发之间严格同步%SNR=input('SNR=');%输入信噪比参数SNR=3:14;%定义信噪比范围BER=zeros(1,length(SNR));baseband_out_length=carrier_count*symbols_per_carrier*bits_per_symbol;%计算发送的二进制序列长度carriers=(1:carrier_count)+(floor(IFFT_bin_length/4)-floor(carrier_count/2));%坐标:(1to200)+156,157--356conjugate_carriers=IFFT_bin_length-carriers+2;%坐标:1024-(157:356)+2=1026-(157:356)=(869:670)%构造共轭时间-载波矩阵,以便应用所谓的RCC,ReducedComputationalComplexity算法,即ifft之后结果为实数%Definetheconjugatetime-carriermatrix%也可以用flipdim函数构造对称共轭矩阵%---------------------------------------------%%信号发射%%---------------------------------------------%%out=rand(1,baseband_out_length);%baseband_out1=round(out);%baseband_out2=floor(out*2);%baseband_out3=ceil(out*2)-1;%baseband_out4=randint(1,baseband_out_length);%四种生成发送的二进制序列的方法,任取一种产生要发送的二进制序列%if(baseband_out1==baseband_out2&baseband_out1==baseband_out3)%fprintf('TransmissionSequenceGenerated\n\n');%baseband_out=baseband_out1;%else%fprintf('CheckCode!!!!!!!!!!!!!!!!!!!!!\n\n');%end%验证四种生成发送的二进制序列的方法baseband_out=round(rand(1,baseband_out_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'方式%-------------------------------------------------------------------------%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_matrix1,bits_per_symbol,'right-msb');%函数说明:%BI2DEConvertbinaryvectorstodecimalnumbers.%D=BI2DE(B)convertsabinaryvectorBtoadecimalvalueD.WhenBis%amatrix,theconversionisperformedrow-wiseandtheoutputDisa%columnvectorofdecimalvalues.Thedefaultorientationofthebinary%inputisRight-MSB;thefirstelementinBrepresentstheleastsignificantbit.%if(modulo_baseband==Test_convert_matrix1')%fprintf('modulo_baseband=Test_convert_matrix1\n\n\n');%elseif(modulo_baseband==Test_convert_matrix2')%fprintf('modulo_baseband=Test_convert_matrix2\n\n\n');%else%fprintf('modulo_baseband~=anyTest_convert_matrix\n\n\n');%end%end%wegettheresultmodulo_baseband=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,,2^bits_per_symbol);%差分调制endcarrier_matrix=carrier_matrix*((2*pi)/(2^bits_per_symbol));%产生差分相位[X,Y]=pol2cart(carrier_matrix,ones(size(carrier_matrix,1),size(carrier_matrix,2)));%由极坐标向复数坐标转化第一参数为相位第二参数为幅度%Carrier_matrixcontainsallthephaseinformationandalltheamplitudesarethesame‘1’.complex_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-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,totally200symbolsasarowtraining_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,IFFT_bin_length);%Herearowvectorofzerosisbetweentrainingsymbolsanddatasymbols!!!%4trainingsymbolsand1zerosymbol%everyOFDMsymboltakesarowofIFFT_modulationIFFT_modulation(:,carriers)=complex_carrier_matrix;IFFT_modulation(:,conjugate_carriers)=conj(complex_carrier_matrix);%-------------------------------------------------------------------------%Testbylavabin--Findtheindicesofzeros%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;%fori=1:symbols_per_carrier%index_of_zeros(i,=find(IFFT_modulation1(i+5,==1);%end%-------------------------------------------------------------------

1 / 9
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功