📄 channelsui.m
字号:
function channel = channelSUI(N_SUI,G,BW)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %
%% Name: channelSUI.m %
%% %
%% Description: It generates the Channel Impulse Response of the %
%% channel variant by using Jakes Model. %
%% %
%% The Channel used depends on the parameters that are indicated %
%% to it. We can simulate SUI channeles 1 to 6, with different %
%% bandwidths. %
%% %
%% Parameters: %
%% N_SUI = Channel to simulate. G = Size of the cyclic prefix %
%% v = Speed of the system. BW = Bandwidth of the channel %
%% %
%% %
%% Authors: Bertrand Muquet, Sebastien Simoens, Shengli Zhou %
%% October 2000 %
%% Modification : Carlos Batlles - April 2007 %
%% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Speed of the receiver 0.001 m/s
v = 0.001;
% We are going to consider that we are sending a unique symbol
FrameLength = 1;
% The following parameters are with which we calculated the duration of the symbol in WiMAX
Nfft = 256;
BW = BW*1e6;
% Factor of correction
if mod(BW,1.75)==0
n = 8/7;
elseif mod(BW,1.5)==0
n = 86/75;
elseif mod(BW,1.25)==0
n = 144/125;
elseif mod(BW,2.75)==0
n = 316/275;
elseif mod(BW,2)==0
n = 57/50;
else
n = 8/7;
end
if N_SUI~=0
Fs = floor(n*BW/8000)*8000; % Sampling frequency
deltaF = Fs / Nfft; % Subcarrier spacing.
Tb = 1/deltaF; % Useful symbol time (data only)
Ts = Tb * (1+G); % OFDM symbol time (data + cyclic prefix)
T = 1/(Fs*1e-6); % Duration in microseconds of each carrier
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% The parameters given back are the following: %
% %
% P --> Power of each path (dB) %
% K --> Factor K of the Ricean distribution (Linear) %
% tau --> Delay of each path (microseconds) %
% Dop --> Maximum Doppler frequency (Hertz) %
% ant_corr --> Coefficient of antenna correlation %
% Fnorm --> Normalizing factor of gain (dB) %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch N_SUI
case 1
powers = [ 0 -15 -20 ];
K = [ 4 0 0 ];
delays = [ 0.0 0.4 0.9 ];
Dop = [ 0.4 0.3 0.5 ];
ant_corr = 0.7;
Fnorm = -0.1771;
case 2
powers = [ 0 -12 -15 ];
K = [ 2 0 0 ];
delays = [ 0.0 0.4 1.1 ];
Dop = [ 0.2 0.15 0.25 ];
ant_corr = 0.5;
Fnorm = -0.3930;
case 3
powers = [ 0 -5 -10 ];
K = [ 1 0 0 ];
delays = [ 0.0 0.4 0.9 ];
Dop = [ 0.4 0.3 0.5 ];
ant_corr = 0.4;
Fnorm = -1.5113;
case 4
powers = [ 0 -4 -8 ];
K = [ 0 0 0 ];
delays = [ 0.0 1.5 4.0 ];
Dop = [ 0.2 0.15 0.25 ];
ant_corr = 0.3;
Fnorm = -1.9218;
case 5
powers = [ 0 -5 -10 ];
K = [ 0 0 0 ];
delays = [ 0.0 4.0 10.0 ];
Dop = [ 2.0 1.5 2.5 ];
ant_corr = 0.3;
Fnorm = -1.5113;
case 6
powers = [ 0 -10 -14 ];
K = [ 0 0 0 ];
delays = [ 0.0 14.0 20.0 ];
Dop = [ 0.4 0.3 0.5 ];
ant_corr = 0.3;
Fnorm = -0.5683;
end
Dop = max (Dop);
%% The delays are normalized
sz=size(delays);
if (and(sz(1) ~= 1,sz(2) == 1)) delays=delays.';
elseif (and(sz(1) ~= 1,sz(2) ~= 1)) 'Error: The delay must be a vector';
end
% Now the delays express themselves in number of samples.
delays=delays/T;
nbtaps=length(powers);
len_cir=1+round(max(delays));
variances=zeros(1,len_cir);
%% Calculate the amplitude of each path.
sz=size(powers);
if (and(sz(1) ~= 1,sz(2) == 1)) powers=powers.';
elseif (and(sz(1) ~= 1,sz(2) ~= 1)) 'Error: The powers must be a vector';
end
%% The powers are in dB -> With this order the variance is calculated to recombine the power of every path
variances2=10.^(powers/10);
%% Normalize the powers
variances2=variances2/sum(variances2);
%% Finally, the discreet CIR is calculated bringing every path to the following sample
for i=1:nbtaps
variances(1+round(delays(i)))=variances(1+round(delays(i)))+ variances2(i);
end
Lc=length(variances)-1;
hfr=[];
fc = 2.3e9; % Carrier Frequency in Hertz (2.5GHz 3.2GHz)
fdmax = Dop;
N = 100; % Number of incident waves
t = Ts:Ts:Ts*FrameLength; % The variable "time"
len = length(t);
theta = rand(1,N)*2*pi; % Generating the uniform phases
fd = cos(2*pi*((1:N)/N))*fdmax; % Generate eqaul-spaced frequencies from "-fdmax" to "+fdmax"
E = exp(j.*(2*pi*fd(:)*t(:)'+repmat(theta(:),1,len)));
E = E/sqrt(N);
fadingcoeff = sum(E);
%plot(t,abs(fadingcoeff))
%xlabel('time (second)');ylabel('Envelope of the fading coefficient');
for ih=1:Lc+1
hfr=[hfr;fadingcoeff];
end
hfr=diag(variances.^0.5)*hfr;
%% hfr has a size of (Lc+1)x(FrameLength)
%% hfr(:,i) It contains the CIR(Channel Impulse Response) corresponding to the transmission of symbol i
% Finally, the values of the channel are normalized.
channel = hfr ./ norm(hfr);
elseif N_SUI == 0
channel = 1; % If an AWGN channel is chosen, the channel will be the unit.
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -