《2022年OFDMMATLAB仿真程序 .pdf》由会员分享,可在线阅读,更多相关《2022年OFDMMATLAB仿真程序 .pdf(3页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、% - % % 参数定义% % - % NumLoop = 1000; NumSubc = 128; NumCP = 8; SyncDelay = 0; % 子载波数128 % 位数 / 符号2 % 符号数 / 载波1000 % 训练符号数0 % 循环前缀长度8 (1/16)*T % 调制方式4-QAM % 多径信道数3 % IFFT Size 128 % 信道最大时延2 % - % % QAM MODULATION % % - % % Generate the random binary stream for transmit test BitsTx = floor(rand(1,NumLo
2、op*NumSubc)*2); % Modulate (Generates QAM symbols) % input: BitsTx(1,NumLoop*NumSubc); output: SymQAM(NumLoop,NumSubc/2) SymQAMtmp = reshape(BitsTx,2,NumLoop*NumSubc/2).; SymQAMtmptmp = bi2de(SymQAMtmp,2,left-msb); % QAM modulation % 00-1-i,01-1+i,10-1-i,11-1+i % 利用查表法进行QAM 星座映射QAMTable = -1-i -1+i
3、1-i 1+i; SymQAM = QAMTable(SymQAMtmptmp+1); % - % % IFFT % % - % % input: SymQAM(NumLoop,NumSubc/2); output: SymIFFT(NumSubc,NumLoop) SymIFFT = zeros(NumSubc,NumLoop); SymIFFTtmp = reshape(SymQAM,NumSubc/2,NumLoop); SymIFFTtmptmp = zeros(NumSubc,NumLoop); SymIFFTtmptmp(1,:) = real(SymIFFTtmp(1,:); %
4、 实数SymIFFTtmptmp(NumSubc/2+1,:) = imag(SymIFFTtmp(1,:); % 实数% 构造共轭对称矩阵名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 3 页 - - - - - - - - - SymIFFTtmptmp(2:NumSubc/2,:) = SymIFFTtmp(2:NumSubc/2,:); SymIFFTtmptmp(NumSubc/2+2):NumSubc,:) = flipdim(conj(SymIFFTtmp(
5、2:NumSubc/2,:),1); SymIFFT = ifft(SymIFFTtmptmp,NumSubc,1); % - % % Add cyclic prefix % % - % % input: SymIFFT(NumSubc,NumLoop); output: SymCP(NumSubc + NumCP,NumLoop) NumAddPrefix = NumSubc + NumCP; SymCP = zeros(NumAddPrefix,NumLoop); RowPrefix = (NumSubc - NumCP + 1):NumSubc; SymCP = SymIFFT(RowP
6、refix,:);SymIFFT; % - % % Go through the channel % % - % % input: SymCP(NumSubc + NumCP,NumLoop); output: SymCh(1,(NumSubc + NumCP)*NumLoop) SymCh = zeros(1,(NumSubc + NumCP)*NumLoop); SymChtmp = SymCP(:).; Ch = 1 1/2 1/4; SymChtmptmp = filter(Ch,1,SymChtmp); % Add the AWGN BerSnrTable = zeros(20,3)
7、; for snr=0:19; % = SNR + 10*log10(log2(2); BerSnrTable(snr+1,1) = snr; SymCh = awgn(SymChtmptmp,snr,measured); % - % % Remove Guard Intervals % % - % % input: SymCh(1,(NumSubc + NumCP)*NumLoop); output: SymDeCP(NumSubc,NumLoop) SymDeCP = zeros(NumSubc,NumLoop); SymDeCPtmp = reshape(SymCh,NumSubc +
8、NumCP,NumLoop); SymDeCP = SymDeCPtmp(NumCP+1+SyncDelay):NumAddPrefix+SyncDelay,:); % - % % FFT % % - % % input: SymDeCP(NumSubc,NumLoop); output: SymFFT(NumSubc,NumLoop) SymFFT = fft(SymDeCP,NumSubc,1); % - % % Make Decision(Include DeQAM) % % - % 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - -
9、 - - 名师精心整理 - - - - - - - 第 2 页,共 3 页 - - - - - - - - - % SymFFT(NumSubc,NumLoop); output: SymDec(NumSubc,NumLoop) SymDec = zeros(NumSubc,NumLoop); SymEqtmp(1,:) = SymFFT(1,:)+i*SymFFT(NumSubc/2+1,:); SymEqtmp(2:NumSubc/2,:) = SymFFT(2:NumSubc/2,:); for m = 1:NumLoop for n = 1:NumSubc/2 Real = real(
10、SymEqtmp(n,m); Imag = imag(SymEqtmp(n,m); if( abs(Real -1) abs(Real +1) SymDec(2*n-1,m) = 1; else SymDec(2*n-1,m) = 0; end if( abs(Imag -1) abs(Imag +1 ) ) SymDec(2*n,m) = 1; else SymDec(2*n,m) = 0; end end end % Bit Error BitsRx = zeros(1,NumSubc*NumLoop); BitsRx = SymDec(:).; Num,Ber = symerr(Bits
11、Tx,BitsRx) BerSnrTable(snr+1,2) = Num ; BerSnrTable(snr+1,3) = Ber ; end figure(1); subplot(2,1,1); semilogy(BerSnrTable(:,1),BerSnrTable(:,2),o-); title(误比特数曲线 );xlabel(SNR/dB);ylabel(误比特数 ); subplot(2,1,2); semilogy(BerSnrTable(:,1),BerSnrTable(:,3),o-); title(误比特数曲线 );xlabel(SNR/dB);ylabel(误比特数 ); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 3 页 - - - - - - - - -