-
Notifications
You must be signed in to change notification settings - Fork 4
/
functionDataFusion.m
62 lines (43 loc) · 1.76 KB
/
functionDataFusion.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function xhat = functionDataFusion(S,K,channelGaindB,numRealizations,x,dataFusion)
% Performs the data fusion step among the received signals at each subarray.
% <p>
% @author Victor Croisfelt <victorcroisfelt@gmail.com>
% </p>
% @param S number of subarrays.
% @param K number of users.
% @param channelGaindB M x K matrix with the channel gain in Decibels for each user when considering pathloss.
% @param numRealizations number of channel realizations (small-fading).
% @param x K x 1 vector with modulated signals sent by all K users.
% @param dataFusion string that contains the data fusion type. Types are: 'DEDF' and 'DLDF'.
% @return xhat K x numRealizations matrix with estimated signals at each channel realization.
%Prepare to save xhat
xhat = zeros(K,numRealizations);
%Check data fusion method
if strcmp(dataFusion,'DEDF')
xhat = mean(x,3);
elseif strcmp(dataFusion,'DLDF')
%Converting dB to linear scale
channelGain = db2pow(channelGaindB);
channelGain(channelGain == 1) = 0;
%Store the sum of the channel gains
overallSNR = reshape(sum(sum(channelGain,1),3),[K 1]);
%Prepare to save the weigths
alpha = zeros(K,S);
%Go through each subarray
for s = 1:S
%Store the sum for each user
subarraySNR = sum(channelGain(:,:,s),1);
%Go through each user
for k = 1:K
%Obtain the weight by performing the ratio
alpha(k,s) = subarraySNR(k)./overallSNR(k);
end
end
%Go through each subarray
for s = 1:S
%Go through each user
for k = 1:K
xhat(k,:) = xhat(k,:) + alpha(k,s)*x(k,:,s);
end
end
end