www.pudn.com > RAKE.rar > ljq_rakeselector.m


%/*-----------------ÐŵÀ¹ÀÖµ----------------*/ 
%------------------------by LinJiaqing----------------------- 
% Simulates channel estimation for a discrete-time channel 
% impulse response 'hf' with time resolution 'ts' in 
% seconds. In addition, the function evaluates the 
% weighting factors to be used in a RAKE receiver 
% implementing Maximal Ratio Combining. 
% 'fc' is the value of the sampling frequency 
% 'L' is the number of coefficients to be used in the 
%  Partial Rake 
% 'S' is the number of coefficients to be used in the 
%  Selective Rake 
% The function returns: 
% 1) a vector 'G' containing all the amplitude coefficients 
%     of the channel impulse response in a descending 
%     order; 
% 2) a vector 'T' containing all the relative delays for 
%     the elements in vector 'G', i.e. T(j) represents the 
%     relative delay of the multipath component having amplitude G(j); 
% 3) the number 'NF' of non-zero contributions of the 
%     channel impulse response; 
% 4) a vector 'Arake' representing the weighting factors to 
%     be used in an ideal RAKE which processes all the 
%     multipath contributions at the receiver input; 
% 5) a vector 'Srake' representing the weighting factors to 
%     be used in a Selective RAKE which processes the best 
%     L multipath contributions at the receiver input;  
% 6) a vector 'Srake' representing the weighting factors to 
%     be used in a Selective RAKE which processes the best 
%     S multipath contributions at the receiver input; 
% 7) a vector 'Prake' representing the weighting factors to 
%     be used in a Partial RAKE which processes the first L 
%     multipath contributions which arrive at the receiver 
%     input. 
function [G,T,NF,Arake,Srake,Prake]=ljq_rakeselector(hf,fc,ts,L,S) 
% ----------------------------- 
% Step One - Channel Estimation 
% ----------------------------- 
dt = 1 / fc; 
ahf = abs(hf); 
[s_val,s_ind] = sort(ahf); 
NF = 0; 
i = length(s_ind); 
j = 0; 
% evaluation of the reference vectors 
% for the RAKE combiner 
while (s_val(i)>0)&(i>0) 
    NF = NF + 1; 
    j = j + 1; 
    index = s_ind(i); 
    I(j) = index; 
    T(j) = (index-1)*dt; 
    G(j) = hf(index); 
    i = i - 1; 
end 
% -------------------------------------------- 
% Step Two - Evaluation of the weighting terms 
% -------------------------------------------- 
binsamples = floor(ts/dt); 
if S > NF 
    S = NF; 
end 
if L > NF 
    L = NF; 
end 
Arake = zeros(1,NF*binsamples); 
Srake = zeros(1,NF*binsamples); 
Prake = zeros(1,NF*binsamples); 
% Selective Rake and All Rake 
for nf = 1 : NF 
    x = I(nf); 
    y = G(nf); 
    Arake(x) = y; 
    if nf <= S 
        Srake(x) = y; 
    end 
end % for nf = 1 : NF 
% Partial Rake 
[tv,ti] = sort(T); 
TV = tv(1:L); 
TI = ti(1:L); 
tc = 0; 
for nl = 1 : length(TV) 
    index = TI(nl); 
    x = I(index); 
    y = G(index); 
    Prake(x) = y; 
    tc = tc + 1; 
    L = L - 1; 
end