: 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:():); % 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
load
load
load
load
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);
% pose each subchannel in the frequency domain
[U S V] = pose_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
MIMO OFDM MATLAB仿真程序一 来自淘豆网m.daumloan.com转载请标明出处.