Files
jens be93069dd0 getRefGain.m
- fixed superpositiion of gain, time and freq references
- RX: beautify plot

git-svn-id: http://moon:8086/svn/matlab/trunk@45 801c6759-fa7c-4059-a304-17956f83a07c
2015-04-30 19:39:04 +00:00

70 lines
1.9 KiB
Matlab

function [ref_c ref_p ref_a] = getRefGain(ofdm_params, spec_occ, s)
k0 = ofdm_params.k0;
x = ofdm_params.x;
y = ofdm_params.y;
s = mod(s, ofdm_params.nspf);
k = k0 + x*mod(s, y) + x*y*(spec_occ.kmin:1:spec_occ.kmax);
k(find(k > spec_occ.kmax)) = [];
k(find(k < spec_occ.kmin)) = [];
n = mod(s, y);
m = floor(s/y);
p = (k - k0 - n*x)/(x*y);
mag = sqrt(2);
ref_a = mag*ones(1,length(k));
ref_c = k;
switch ofdm_params.mode
case 'A'
ref_p = mod(4*ofdm_params.Z(n+1,m+1) + p*ofdm_params.W(n+1,m+1) + p.*p*(1+s)*ofdm_params.Q, 1024);
case 'B'
ref_p = mod(4*ofdm_params.Z(n+1,m+1) + p*ofdm_params.W(n+1,m+1) + p.*p*(1+s)*ofdm_params.Q, 1024);
case 'C'
ref_p = mod(4*ofdm_params.Z(n+1,m+1) + p*ofdm_params.W(n+1,m+1) + p.*p*(1+s)*ofdm_params.Q, 1024);
case 'D'
ref_p = mod(4*ofdm_params.Z(n+1,m+1) + p*ofdm_params.W(n+1,m+1) + p.*p*(1+s)*ofdm_params.Q, 1024);
case 'E'
ref_c = [];
ref_p = [];
ref_a = [];
error ('Implement Mode E!');
end;
% Fix superposition of carriers
[freqRef_c, freqRef_p, freqRef_a] = getRefFreq(ofdm_params.mode);
[ref_c, ref_p, ref_a] = fix_superposition(ref_c, ref_p, ref_a, freqRef_c, freqRef_p, freqRef_a);
if (s == 0)
[timeRef_c, timeRef_p, timeRef_a] = getRefTime(ofdm_params.mode);
[ref_c, ref_p, ref_a] = fix_superposition(ref_c, ref_p, ref_a, timeRef_c, timeRef_p, timeRef_a);
end
for b=spec_occ.boost
ref_a(find(ref_c == b)) = sqrt(4);
end
function [new_c, new_p, new_a] = fix_superposition(ref_c, ref_p, ref_a, super_c, super_p, super_a)
new_c = ref_c;
new_p = ref_p;
new_a = ref_a;
super_index = 1;
for c=super_c
curr_index = find(ref_c == c);
if (~isempty(curr_index))
new_p(curr_index) = super_p(super_index);
new_a(curr_index) = super_a(super_index);
end
super_index = super_index + 1;
end