-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_mimo2_SNRs.m
54 lines (49 loc) · 1.47 KB
/
get_mimo2_SNRs.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
%GET_MIMO2_SNRS Calculates the MIMO2 SNRs for a scaled CSI matrix.
% Note that the matrix is expected to have dimensions M x N x S, where
% M = # TX antennas
% N = # RX antennas
% S = # subcarriers
%
% (c) 2008-2011 Daniel Halperin <[email protected]>,
% Wenjun Hu
%
function ret = get_mimo2_SNRs(csi)
% Make sure at least 2 TX and RX antennas
[M N S] = size(csi);
if (M < 2)
error('CSI matrix must have at least 2 TX antennas');
end
if (N < 2)
error('CSI matrix must have at least 2 RX antennas');
end
% Since the incoming CSI is scaled to single-TX reduce by 2 for 2 streams
csi = csi / sqrt(2);
% Separate out 3 and 2 antenna cases
if M == 2
ret = zeros(1,2,S);
for i = 1:S
ret(1,:,i) = mimo2_mmse(squeeze(csi(:,:,i)));
end
return;
end
% else M == 3
% There are 3 TX configs: TX AB, AC, BC
ret = zeros(3,2,S);
for i = 1:S
ret(1,:,i) = mimo2_mmse(squeeze(csi([1 2],:,i)));
ret(2,:,i) = mimo2_mmse(squeeze(csi([1 3],:,i)));
ret(3,:,i) = mimo2_mmse(squeeze(csi([2 3],:,i)));
end
return;
end
% Compute the MMSE stream SNRs of a single channel matrix
function ret = mimo2_mmse(csi)
% We want
% H' * H + I
% but, since csi = H transposed, we instead use
% conj(csi) * csi.'
M = inv(conj(csi) * csi.' + eye(2));
ret = 1 ./ diag(M) - 1;
% ret is real. Really.
ret = real(ret);
end