📄 syn_m1.m
字号:
% syn_m1.m
% Simulation program to see the correlated peak under AWGN channel
%********************** preparation part ***************************
clear;
para=2048; % Number of parallel channel to transmit (points)
fftlen=2048; % FFT length
noc=2048; % Number of carrier
nd=6; % Number of information OFDM symbol for one loop
ml=4; % Modulation level : 16QAM
sr=250000; % Symbol rate
br=sr.*ml; % Bit rate per carrier
gilen=64; % Length of guard interval (points)
ebn0=7; % Eb/N0
z=ebn0/(ebn0+1)/2; % corelated factor of ML algorithm
T=1:3*noc+2*gilen; %length of FFT window removes
%************************** transmitter *********************************
%************************** Data generation ****************************
seldata=rand(1,para*nd*ml)>0.5; % rand : built in function
%****************** Serial to parallel conversion ***********************
paradata=reshape(seldata,para,nd*ml); % reshape : built in function
%************************** QPSK modulation *****************************
[ich,qch]=qpskmod(paradata,para,nd,ml);
kmod=1/sqrt(2); % sqrt : built in function
ich1=ich.*kmod;
qch1=qch.*kmod;
%******************* IFFT ************************
x=ich1+qch1.*i;
y=ifft(x); % ifft : built in function
ich2=real(y); % real : built in function
qch2=imag(y); % imag : built in function
%********* Gurad interval insertion **********
[ich3,qch3]= giins(ich2,qch2,fftlen,gilen,nd);
fftlen2=fftlen+gilen;
%********* Attenuation Calculation *********
spow=sum(ich3.^2+qch3.^2)/nd./para; % sum : built in function
attn=0.5*spow*sr/br*10.^(-ebn0/10);
attn=sqrt(attn);
%*************************** Receiver *****************************
%***************** AWGN addition *********
[ich4,qch4]=comb(ich3,qch3,attn);
%******************* quantization*******************************
ich5=sign(ich4);
qch5=sign(qch4);
r=ich5+qch5*i;
%**************************** ML estimation *******************************
for ii=1:length(T); % FFT窗移动的距离
data1=r(ii:gilen+ii-1); % 取gilen长个数据存data1
data2=r(noc+ii:noc+gilen+ii-1); % 取相距noc的gilen长个数据存data2
s=data1*data2'; %求互相关值
cor(ii)=abs(s); % abs: built in function
%********************** 求能量项 **********************
data11=abs(data1).^2;
data22=abs(data2).^2;
data3=(data11+data22)*z;
data33=sum(data3); % sum : built in function
con(ii)=data33;
%********************* 时间变量估计样本值 ***************
data4(ii)=cor(ii)-con(ii);
end
%****************** plot ************************
plot(T,data4);
xlabel('载波数');ylabel('相关值');
%********** end of file ******************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -