📄 sfading_channel.m
字号:
function out=sfading_channel(input,d_counter)
%****************** variables *************************
% idata input Ich data
% qdata input Qch data
% iout output Ich data
% qout output Qch data
% ramp : Amplitude contaminated by fading
% rcos : Cosine value contaminated by fading
% rsin : Cosine value contaminated by fading
% itau : Delay time for each multipath fading
% dlvl : Attenuation level for each multipath fading
% th : Initialized phase for each multipath fading
% n0 : Number of waves in order to generate each multipath fading
% itn : Initial Fading counter for each multipath fading
% n1 : Number of summation for direct and delayed waves
% nsamp : Total number od symbols
% tstp : Mininum time resolution
% fd : Maxmum doppler frequency
% flat flat fading or not
% (1->flat (only amplitude is fluctuated),0->nomal(phase and amplitude are fluctutated)
%******************************************************
% dcounter : In oder to
%%%%%-----------------channel parameters----------------------
%%%************ Main adjusted parameter***********************
np=24; %%% number of paths
Dexp=2; %%% Interval time of adjacent two pathes (number of sample points)
fd=10; %%% maximum Doppler frequency
%%%***********************************************************
flat=0; %%% General condition
tstp=0.0125*10^(-6); %%% sample duration (Tsam)
br=1/tstp; %%% sample rate
dt=Dexp*tstp; %%% delay between two paths is Dexp*tstp (us)
delay_time=[0:dt:(np-1)*dt]; %%% the unit is us
itau=floor(delay_time./tstp); %%% number of delayed points
df=0.5; %%% fading step length, the unit is dB
dlvl=[0:df:(np-1)*df];
th=zeros(1,np); %%% unit is degree
n0=[6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7,6,7];
%n0=6;
%itn=[1000:1000:np*1000]; %%% or [800:1000:(np-1)*1000+1000]
itn=[1000:500000:np*500000]; %%% The best interval is 5/(fd*tstp)
%%% counter_test can test the optimal itn and itn0
%itn0=5000;
counter=itn+d_counter;
n1=np; %%% number of paths
%%%-------------End of channel parameters--------------------
nsamp=length(input); %%% nsamp=50/(fd*Ts) is better
idata=real(input);
qdata=imag(input);
iout = zeros(1,nsamp);
qout = zeros(1,nsamp);
%ps=sum(idata.^2+qdata.^2)/length(idata)
total_attn = sum(10 .^( -1.0 .* dlvl ./ 10.0));
for k = 1 : np
atts = 10.^( -0.05 .* dlvl(k)); %%% amplitude factor of fading
if dlvl(k) >= 40.0
atts = 0.0;
end
theta = th(k) .* pi ./ 180.0; %%% change the unit of degree into radian
%%%%%%------------delay-----------------------
itmp=[zeros(1,itau(k)),idata(1:nsamp-itau(k))];
qtmp=[zeros(1,itau(k)),qdata(1:nsamp-itau(k))];
%%%%%%-----------------------------------------------------
[itmp3,qtmp3,ramp,rcos,rsin] = fade (itmp,qtmp,nsamp,tstp,fd,n0(k),counter(k),flat);
iout = iout + atts .* itmp3 ./ sqrt(total_attn);
qout = qout + atts .* qtmp3 ./ sqrt(total_attn);
end
%itn=itn+itn0;
out=iout+j*qout;
%%%----------------End--------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -