⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ofdmce6.m

📁 这些代码包括ofdm的实现和信道估计,可以运行,有指导程序的说明文档.
💻 M
字号:
% ofdmce6.m
%64个子在波
%
function[ber,per]=ofdmce6(snr_in_db)
%********************** preparation part ***************************
para=64;    % Number of parallel channel to transmit (points)
fftlen=64;  % FFT length
noc=53;     % Number of carriers
nd=6;       % Number of information OFDM symbol for one loop
knd=1;      % Number of known channel estimation (CE) OFDM symbol
ml=2;       % Modulation level : QPSK
sr=250000;  % OFDM symbol rate (250 ksyombol/s)
br=sr.*ml;  % Bit rate per carrier
gilen=16;   % Length of guard interval (points)
ebn0=snr_in_db;
%%%%%%%%%%%%% fading initialization %%%%%%%%%%%

tstp=1/sr/(fftlen+gilen); % Time resolution
itau=[0,2];       % Arrival time for each multipath normalized by tstp 
dlvl1=[0,10];      % Mean power for each multipath normalized by direct wave.
n0=[6,7];	        % Number of waves to generate fading n0(1),n0(2)
th1=[0.0,0];      % Initial Phase of delayed wave
itnd1=[1000,2000];   % set fading counter        	
now1=2;         % Number of directwave + Number of delayed wave
fd=150;         % Maximum Doppler frequency
flat=1;         % Flat or not (see ofdm_fading.m)
itnd0=nd*(fftlen+gilen)*20; % Number of fading counter to skip 

%************************** main loop part **************************

nloop=1000;  % Number of simulation loops

noe = 0;    % Number of error data
nod = 0;    % Number of transmitted data
eop=0;      % Number of error packet
nop=0;      % Number of transmitted packet

%************************** transmitter *****************************
for iii=1:nloop
seridata=rand(1,para*nd*ml)>0.5;  %  DC=0

paradata=reshape(seridata,para,nd*ml); %size(51  *  nd*ml)

%-------------- ml modulation ---------------- 

[ich,qch]=qpskmod(paradata,para,nd,ml);
kmod=1/sqrt(2);
ich=ich.*kmod;
qch=qch.*kmod;
kndata=zeros(1,para);
kndata0=2.*(rand(1,para)>0.5)-1;
kndata=kndata0;
ceich=kndata; 
ceqch=zeros(1,para);

%------------- data mapping (DC=0) -----------
ich1=ich;
qch1=qch;

ich2=[ceich.' ich1]; % I-channel transmission data
qch2=[ceqch.' qch1]; % Q-channel transmission data

%------------------- IFFT  -------------------

x=ich2+qch2.*i;
y=ifft(x,fftlen);
ich3=real(y);
qch3=imag(y);


%---------- Gurad interval insertion ---------

fftlen2=fftlen+gilen;
[ich4,qch4]= giins(ich3,qch3,fftlen,gilen,nd+1);

%---------- Attenuation Calculation ----------

spow=sum(ich4.^2+qch4.^2)/nd./para;
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);


%********************** fading channel ****************************** 

[ifade,qfade,ramp,rcos,rsin]=sefade(ich4,qch4,itau,dlvl1,th1,n0,itnd1,now1,length(ich4),tstp,fd,flat);
itnd1 = itnd1+itnd0;  % Updata fading counter
ich4=ifade;
qch4=qfade;

%***************************  Receiver  *****************************
%--------------- AWGN addition --------------- 
[ich5,qch5]=comb(ich4,qch4,attn);

%----------- Guard interval removal ----------
[ich6,qch6]= girem(ich5,qch5,fftlen2,gilen,nd+1);

%------------------  FFT  --------------------
rx=ich6+qch6.*i;
ry=fft(rx,fftlen);
ich7=real(ry);
qch7=imag(ry);


%---------- CE symbol removal ----------------

ich8=ich7(:,knd+1:nd+1);
qch8=qch7(:,knd+1:nd+1);
ich9=ich8;
qch9=qch8;
%----------------- demoduration --------------

ich10=ich9./kmod;
qch10=qch9./kmod;
[demodata]=qpskdemod(ich10,qch10,para,nd,ml);   

%--------------  error calculation  ----------

demodata1=reshape(demodata,1,para*nd*ml);
noe2=sum(abs(demodata1-seridata));
nod2=length(seridata);

% calculating PER
if noe2~=0
   eop=eop+1;
else
   eop=eop;
end   
   eop;
   nop=nop+1;
   
% calculating BER
noe=noe+noe2;
nod=nod+nod2;

fprintf('%d\t%e\t%d\n',iii,noe2/nod2,eop);
   
end

per=eop/nop;
ber=noe/nod;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -