📄 main_80216e.m
字号:
%--------------------------------------------------------------------------
% This is the simulation of Wimax(802.16e) downlink and has been simplified
% to compare the performance of different channel estimation algorithm
% between Ls and Lmmse,at the end also give the BER of Ls , Lmmse , and no
% channel estimation effect.
% Reference: IEEE Std 802.16e-2005
% Author: quan ningbo (权宁波)
% E-mail & MSN: askningbo@hotmail.com
% Release Data : July 6th, 2007
% If you have any suggestions and ideas ,don't hesitate to contact me.
%--------------------------------------------------------------------------
clc;
clear;
Num1=576; % 导频数目 (按照每帧26符号,但可用的为24符号计算分配)
Num2=13824; % 数据数目
Length_fft=1024;
CP=1/8;
GI=Length_fft*CP; % 128
Ts=1e-7;% Bw=8.75Hz
% n=8/7
% G=1/8
% fs=Bw*n=1e7Hz
% f(delta)=fs/Num1=1e7/1024=9.765625kHz
% Tb=0.1024ms
% Tg=G*Tb=0.0128ms=12.8us
%--------------------------------------------------------send part
% 产生导频和数据(导频用BPSK调制,数据用16QAM调制)
[Pilot,Data,Data_bit]=generation(Num1,Num2);
%插入导频于数据中组成帧格式
Frame=Insertpilot(Pilot,Data);
%IFFT调制
D_modulation=ifft(Frame,Length_fft);
%加循环前缀
D_addCP=addCP(D_modulation,GI);
%并串变换
D_send=reshape(D_addCP,1,1152*26); % signal for send Tx
%循环测试
BER_LS=[];
BER_LMMSE=[];
BER_1=[];
snr_intelv=1;
N_snr=15;
for snr_db=0:snr_intelv:N_snr
SNR=snr_db;
error_num_LS=0;
error_num_LMMSE=0;
error_num_1=0;
%-------------------------------------------------------channel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1sh channel 通过AWGN信道
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
D_receive=AWGN_channel(D_send,SNR);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 2th channel 通过频率选择性多径信道
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%参数设置================
loop_num=1; %共仿真loop_num次 (每个dB下信道的仿真次数)
for l=1:loop_num
num=5;% 多径数为5条
% 假设功率延迟谱服从负指数分布~exp(-t/trms),trms=(1/4)*cp时长;
% t在0~cp时长上均匀分布
% 取5径延迟如下
delay=[0 2 4 8 10]*1e-6;
trms=3.2e-6;
var_pow=10*log10(exp(-delay/trms));
fd=100; % 最大doppler频率为100Hz
t_interval=1e-7; % 采样间隔为0.1us t_interval为离散信道抽样时间间隔,等于OFDM符号长度/(子载波个数+cp长度lp);
counter=200000; % 各径信道的采样点间隔,应该大于信道采样点数()
count_begin=(l-1)*(5*counter);%每次仿真信道采样的开始位置
trms_1=trms/t_interval;
t_max=10e-6/t_interval;
snr=10^(SNR/10);
D_receive_2=multipath_chann(D_receive,num,var_pow,delay,fd,t_interval,counter,count_begin);
%--------------------------------------------------------receive part
%串并变换
D_ps=reshape(D_receive_2,1152,26);
%去循环前缀
D_offCP=offCP(D_ps,GI);
%FFT解调
D_demodulation=fft(D_offCP,Length_fft);% 1024*26
%为了和其他模块统一接口,从这里开始将对矩阵的处理转换为对向量的处理
%并串转换
D_demodulation_serial=reshape(D_demodulation,1,1024*26);% 行向量,1*26624 复数
%==========M-file均衡===================================================
%=======================================================================
%提取导频
P1=getpilot(D_demodulation_serial);
%%%%%%%%%%%%%%%%%%%%%%%%%%
% Ls rule %
%%%%%%%%%%%%%%%%%%%%%%%%%%
Hp_LS=channelestimation_LS(P1,Pilot); %信道估计LS(得到导频位置的信道频率响应Hp(k))
H_LS=neicha(Hp_LS); %内插(利用导频位置的信道频响内插而得到数据位置上的频响 H(k))
D_after_equalization_LS=equalization(D_demodulation_serial,H_LS); %均衡(只对数据载频处进行均衡)
%比较
%H_LS_spline=neicha_spline(Hp_LS); %采用cubic 插值方法
%D_after_equalization_LS_1=equalization(D_demodulation_serial,H_LS_spline);
%%%%%%%%%%%%%%%%%%%%%%%%%
% LMMSE rule %
%%%%%%%%%%%%%%%%%%%%%%%%%
Hp_LMMSE=channelestimation_LMMSE(P1,Pilot,trms_1,t_max,snr,Hp_LS); %信道估计LMMSE(得到导频位置的信道频率响应Hp(k))
H_LMMSE=neicha(Hp_LMMSE); %内插(利用导频位置的信道频响内插而得到数据位置上的频响 H(k))
D_after_equalization_LMMSE=equalization(D_demodulation_serial,H_LMMSE); %均衡(只对数据载频处进行均衡)
%比较
%H_LMMSE_spline=neicha_spline(Hp_LMMSE); %采用cubic 插值方法
%D_after_equalization_LMMSE_1=equalization(D_demodulation_serial,H_LMMSE_spline);
%=========均衡结束======================================================
%=======================================================================
%从帧中取出数据
D_getdata_LS=getdata(D_after_equalization_LS); %均衡后的数据(Ls均衡)
D_getdata_LMMSE=getdata(D_after_equalization_LMMSE); %均衡后的数据(Lmmse均衡)
D_getdata_1=getdata(D_demodulation_serial); %均衡前的数据(无均衡)
%plot星座图
flag=0;
if(flag==1)
I=real(D_getdata_LS);
Q=imag(D_getdata_LS);
II=real(D_getdata_LMMSE);
QQ=imag(D_getdata_LMMSE);
III=real(D_getdata_1);
QQQ=imag(D_getdata_1);
subplot(3,1,1);plot(I,Q,'.r')
subplot(3,1,2);plot(II,QQ,'.')
subplot(3,1,3);plot(III,QQQ,'.g')
end
%16QAM解调
D_16qam_demodu_LS=demodu_16qam(D_getdata_LS);
D_16qam_demodu_LMMSE=demodu_16qam(D_getdata_LMMSE); %均衡后的数据
D_16qam_demodu_1=demodu_16qam(D_getdata_1); %均衡前的数据
%-------------------------------------------------------------- counter
%统计误比特率(解调之后的比特)
error_num_LS=error_num_LS+length(find(D_16qam_demodu_LS~=Data_bit));
error_num_LMMSE=error_num_LMMSE+length(find(D_16qam_demodu_LMMSE~=Data_bit)); %均衡后的数据
error_num_1=error_num_1+length(find(D_16qam_demodu_1~=Data_bit)); %均衡前的数据
end % loop_num/SNR end
error_ratio_LS=error_num_LS/(length(Data_bit)*loop_num);
error_ratio_LMMSE=error_num_LMMSE/(length(Data_bit)*loop_num);
error_ratio_1=error_num_1/(length(Data_bit)*loop_num);
BER_LS=[BER_LS,error_ratio_LS];
BER_LMMSE=[BER_LMMSE,error_ratio_LMMSE];
BER_1=[BER_1,error_ratio_1];
end % SNR end
figure(3)
i=0:snr_intelv:N_snr;
semilogy(i,BER_LS,'r-*');
hold on;
semilogy(i,BER_LMMSE,'b-o')
hold on
semilogy(i,BER_1,'g-+');
hold on;
grid on;
xlabel('SNR in DB');
ylabel('BER');
title('compare the performance of Ls and Lmmse algorithm');
legend('LS Channel Estimation','LMMSE Channel Estimation','No Channel Estimation');
hold off
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -