OFDMMATLAB仿真程序分析和总结.docxVIP

  • 2
  • 0
  • 约1.01万字
  • 约 8页
  • 2023-08-06 发布于上海
  • 举报
OFDM.m: OFDM Simulator (outer function) clear all; A = [1 1/exp(1) 1/exp(2)]; % power delay profile N = 64; % number of symbols in a single OFDM symbol GI = 16; % guard interval Mt = 1; % number of Tx antennas Mr = 1; % number of Rx antennas sig2 = 1e-3; % noise variance M = 8; % max constellation bit number Mgap = 10.^(1:(1.7/10):2.7); % gap Btot = 100*Mt; % total # bits per OFDM symbol TransmitIter = 50; % # iterations of symbol transmissions for each channel instance ChannelIter = 100; % # iterations of independent identically distributed channel instances GapIter = length(Mgap); load ENC2.mat load ENC4.mat load ENC16.mat load ENC64.mat load ENC256.mat TotEbNo = []; Errors =[]; EbNo = []; for lGap = 1:GapIter lGap gap = Mgap(lGap); totalErrors = 0; for lChan = 1:ChannelIter % create channel [H h_f]=create_channel(Mt, Mr, A, N+GI); % decompose each subchannel in the frequency domain [U S V] = svd_decompose_channel(Mt, Mr, h_f, N); % bitloading [bits_alloc,energy_alloc] = BitLoad(S,Btot,Mt*N,gap,sig2,M); %energy_alloc=energy_alloc/(mean(energy_alloc)); %energy_alloc=ones(1,128); for lTrans = 1:TransmitIter % bits to transmit x = (randn(1,Btot)0); % modulate x_mod = modulate(x,bits_alloc,energy_alloc, s2,s4,s16,s64,s256); % precode modulated signal x_pre = precode(Mt, x_mod, V, N); % ifft, with cyclic prefix for each antenna ofdm_symbol =[]; for i=1:Mt ofdm_symbol = [ofdm_symbol; ifft_cp_tx_blk(x_pre(i:Mt:Mt*(N-1)+i),N,GI)]; end ofdm_symbol2 = reshape(ofdm_symbol,Mt*(N+GI),1); % channel y = transpose(channel(sig2, Mt, Mr, ofdm_symbol2, H, N+GI)); % fft rec_symbol =[]; for i=1:Mt rec_symbol = [rec_symbol; fft_cp_rx_blk(y(i:Mt:Mt*(N+GI-1)+i),N,GI)]; end rec_symbol2 = reshape(rec_symbol,1,Mt*N); % shape received signal shaped_vals = shape(rec_symbol2, Mr, U, N); % demodulate y_demod = demodulate(shaped_vals, bits_alloc, energy_alloc, S, s2,s4,s16,s64,s256, c2,c4,c16,c64,c256); % comparison totalErrors = totalErrors + sum(xor(y_demod,x)); end EbNo = [EbNo sum(energy_all

文档评论(0)

1亿VIP精品文档

相关文档