📄 cp0802_ieeeuwb.m
字号:
%
% FUNCTION 8.8 "cp0802_IEEEuwb"
%
% Generates the channel impulse response for a multi-path channel according
% to the statistical model proposed by the IEEE 802.15.SG3a
%
% 'fc' is the sampling frequency
% 'TMG' is the total multi-path gain
%
% The function returns:
% 1) the channel impulse response 'h0'
% 2) the equivalent discrete time impulse response 'hf'
% 3) the value of the observation time 'OT'
% 4) the value of the resolution time 'ts'
% 5) the value of the total multi-path gain 'X'
%
function [h0,hf,OT,ts,X]=cp0802_IEEEuwb(fc,TMG);
%-----------------------------------------------------
% Step Zero - Input parameters
%-----------------------------------------------------
OT=300e-9; % observation time [s]
ts=2e-9; % time resolution [s]
LAMBDA=0.0233*1e9; % cluster arrival rate (1/s)
lambda=2.5e9; % ray arrival rate (1/s)
GAMMA=7.1e-9; % cluster decay factor
gamma=4.3e-9; % ray decay factor
sigma1=10^(3.3941/10); % stdev of the cluster fading
sigma2=10^(3.3941/10); % stdev of the ray fading
sigmax=10^(3/10); % stdev of log-normal shadowing
rdt=0.001; % ray decay threshold
% rays are neglected when exp(-t/gamma)<rdt
PT=50; % peak threshold [dB]
% rays are considerd if their amplitude is withing the
% -PT range with respect to the peak
G=1; % G=1 ----------->graphical output
% G=0 ----------->no graphical output
%-----------------------------------------------------
% Step One - Cluster characterization
%-----------------------------------------------------
dt=1/fc; % sampling time
T=1/LAMBDA; % average cluster inter-arrival time [s]
t=1/lambda; % average ray inter-arrival time [s]
i=1;
CAT(i)=0; % first cluster arrival time
next=0;
while next<OT;
i=i+1;
next=next+expinv(rand,T);
if next<OT
CAT(i)=next;
end
end %while remaining>0
%-----------------------------------------------------
% Step Two - Path characterization
%-----------------------------------------------------
NC=length(CAT); % number of observed clusters
logvar=(1/20)*((sigma1^2)+(sigma2^2))*log(10);
omega=1;
pc=0; % path counter
for i=1:NC
pc=pc+1;
CT=CAT(i); % cluster time
HT(pc)=CT;
next=0;
mx=10*log(omega)-(10*CT/GAMMA);
mu=(mx/log(10))-logvar;
a=10^((mu+(sigma1*randn)+(sigma2*randn))/20);
HA(pc)=((rand>0.5)*2-1).*a;
ccoeff=sigma1*randn; % fast fading on the cluster
while exp(-next/gamma)>rdt
pc=pc+1;
next=next+expinv(rand,t);
HT(pc)=CT+next;
mx=10*log(omega)-(10*CT/GAMMA)-(10*next/GAMMA);
mu=(mx/log(10))-logvar;
a=10^((mu+ccoeff+(sigma2*randn))/20);
HA(pc)=((rand>0.5)*2-1).*a;
end
end % for i=1:NC
% weak peak filtering
peak=abs(max(HA));
limit=peak/10^(PT/10);
HA=HA.*(abs(HA)>(limit.*ones(1,length(HA))));
for i=1:pc
itk=floor(HT(i)/dt);
h(itk+1)=HA(i);
end
%-------------------------------------------------------------
% Step Three - Discrete time impulse response
%-------------------------------------------------------------
N=floor(ts/dt);
L=N*ceil(length(h)/N);
h0=zeros(1,L);
hf=h0;
h0(1:length(h))=h;
for i=1:(length(h0)/N)
tmp=0;
for j=1:N
tmp=tmp+h0(j+(i-1)*N);
end
hf(1+(i-1)*N)=tmp;
end
% energy normalization
E_tot=sum(h.^2);
h0=h0/sqrt(E_tot);
E_tot=sum(hf.^2);
hf=hf/sqrt(E_tot);
% log-normal shadowing
mux=((10*log(TMG))/log(10))-(((sigmax^2)*log(10))/20);
X=10^((mux+(sigmax*randn))/20);
h0=X.*h0;
hf=X.*hf;
%=======================================================
% Step Four - Graphical output
%=======================================================
if G
Tmax=dt*length(h0);
time=(0:dt:Tmax-dt);
figure(1);
S1=stem(time,h0);
AX=gca;
set(AX,'FontSize',14);
T=title('Channel Impulse Response');
set(T,'FontSize',14);
x=xlabel('Time [s]');
set(x,'FontSize',14);
y=ylabel('Ampulitude Gain');
set(y,'FontSize',14);
figure(2);
S2=stem(time,hf);
AX=gca;
set(AX,'FontSize',14);
T=title('Discrete Time Impulse Response');
set(T,'FontSize',14);
x=xlabel('Time [s]');
set(x,'FontSize',14);
y=ylabel('Amplitude Gain');
set(y,'FontSize',14);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -