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

📄 ofdm44.m

📁 信道编码采用卷积码
💻 M
字号:
%ofdm44.m
%16QAM调制、两径瑞利信道(延迟时间未超过保护间隔)下仿真程序
%**********************初始参数***************************
para=52;       %并行信道数
fftlen=64;     %FFT长度
noc=52;        %载波数
nd=3;          %每循环中OFDM符号数
ml=4;          %调制水平:QPSK
gilen=16;      %保护问隔长度(points)
ebn0=35;       %信噪比
sr=250000;     %OFDM symbol rate (250 ksyombol/s)
br=sr.*ml;     %Bit rate per carrier
%**********************衰落初始值****************************

tstp=1/sr/fftlen+gilen);          % 判决时间
itau=[0 32];                      % 由tstp归一化的到达时间
dlvl1=[0 15];                     % 由直接波归一化的每径能量
n0=[6 7];                         % 产生衰落的波数
itnd1=[1000 2000];                % 衰落计数器
now1=2;                           % 路径数
fd=150;                           % 最大多普勒频率
flat=1;                           % 衰落模式
itnd0=nd*(fftlen+gilen)*10;       % 每次更新的间隔
%**************************主循环部分**************************
nloop=300;     %仿真的循环数
noe1=0;        %信道解码前错误数据数
nod1=0;        %信道解码前传输数据数
noe2=0;        %信道解码后错误数据数
nod2=0:        %信道解码后传输数据数
%**************************发射机*********************************
for iii=l:nloop
%**************************数据产生****************************
%信源编码
t=[0:pi/25:2*pi]:
xx=sin(t);
init=[-1:0.1:1];
partition=[-1:0.1:0.9];
predictor=[0 1];
encode=dpcmenco(xx,init,partition,predictor);
encode2=reshape(encode,51,1);
bin=deci22bin(encode2,6);
recode=reshape(bin,1,306);
%信道编码
k0=1;
G=[1 0 1 1 0 1 1;1 1 1 1 0 0 1];
channelencode=cnv_encd(G,kO,recode);
%******************串并转换***********************
paradata=reshape(channelencode,para,nd*ml); %  reshape:内建功能
%**************************16QAM调制*****************************
[ich,qch]=qpskmod2(paradata,para,nd,ml);

%数据映射
[ich1,qch1]=crmapping(ich,qch,fftlen,nd);
%*******************IFFT************************
x=ich1+qch1.*i;
y=ifft(x);         %ifft:内建功能
ich2=real(y);      %real:内建功能
qch2=imag(y);      %imag:内建功能

%*********插入保护问隔**********
[ich3,qch3]=giins1(ich2,qch2,fftlen,gilen,nd);
fftlen2=fftlen+gilen;
%-------------Attenuation Calculation-----------
spow=sum(ich3.^2+qch3.^2)/nd./para;     % sun:内建功能
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);
%**********************瑞利衰落信道******************
%仿真瑞利衰落信道时,去除“%”
[ifade,qfade]=sefade(ich3,qch3,itau,dlvl1,n0,itnd1,now1,length(ich3),tstp,fd,flat);
itnd1=itnd1+itnd0;                % 更新 fading counter
ich3=ifade;
qch3=qfade;

%-------------AWGN addition----------------------
[ich4,qch4]=comb(ich3,qch3,attn);

%***************去除保护间隔****************
[ich5,qch5]=girem1(ich4,qch4,fftlen2,gilen,nd);

%******************FFT*********************
rx=ich5+qch5.*i;
ry=fft(rx);
ich6=real(ry);
qch6=imag(ry);

%载波逆映射
[ich7,qch7]=crdemapping(ich6,qch6,fftlen,nd);

%*********************解调*******************

[demodata]=qpskdemod1(ich7,qch7,para,nd,ml);

%****************并串转换********************
demodata1=reshape(demodata,1,para*nd*ml);
%信道解码
[channeldecode]=viterbi(G,k0,demodata1);

%信源解码
reshapechanneldecode=reshape(channeldecode,51,6);
deci=bin22deci(reshapechanneldecode);
redeci=reshape(deci,1,51);
codebook=[-1:0.1:5.3];
decode=dpcmdeco(redeci,codebook,predictor);

%*************Bit Error Rate(BER)****************
noe10=sum(abs(demodata1-channelencode));
nod10=length(channelencode);
noe20=sum(abs(channeldecode-recode));
nod20=length(recode);

noe1=noe10+noe1;
nod1=nod10+nod1;
noe2=noe20+noe2;
nod2=nod20+nod2;

fprintf('%d\t%e\t%e\n',iii,noe10/nod10,noe20/nod20);

end

ber1=noe1/nod1;
ber2=noe2/nod2;

%****************输出结果**********************

fprintf('%f\t%e\t%e\t%d\t\n',ebn0,ber1,ber2,nloop);

%*****************end of file*****************




⌨️ 快捷键说明

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