- fixed getRefTime.m

- fixed getRefGain.m
- minor changes to RX/TX

git-svn-id: http://moon:8086/svn/matlab/trunk@43 801c6759-fa7c-4059-a304-17956f83a07c
This commit is contained in:
2015-04-29 21:25:46 +00:00
parent dd733db287
commit 584d16e3bf
4 changed files with 25 additions and 25 deletions
+19 -15
View File
@@ -1,9 +1,9 @@
% function ofdm_tx(N_frames)
function [yv xv] = ofdm_tx(mode, bandwidth, N_frames, withData)
function [yv xv] = ofdm_tx(mode, bandwidth, N_frames, withData, plot_speed)
close all;
DO_PLOT = 0;
DO_PLOT = (plot_speed > 0);
WITH_RCWIN = 1;
WITH_FREQ_REF = 1;
WITH_TIME_REF = 1;
@@ -49,7 +49,6 @@ ofdm_spec_occ.kmin
ofdm_spec_occ.kmax
for k=1:N_frames
for sym_count=0:ofdm_params.nspf-1,
X = zeros(N,1);
% Data
@@ -59,27 +58,28 @@ for k=1:N_frames
X(data_i) = qlut(sym);
end;
if WITH_GAIN_REF == 1
[ref_c ref_p ref_a] = getRefGain(ofdm_params, ofdm_spec_occ, sym_count);
X(c2i(N, ref_c)) = ref_a.*(exp(2*pi*i*ref_p/1024));
end;
if (sym_count==0) & (WITH_TIME_REF == 1)
[ref_c ref_p ref_a] = getRefTime(ofdm_params.mode);
bins = c2i(N, ref_c);
X(bins) = ref_a.*(exp(2*pi*i*ref_p/1024));
X(bins) = ref_a.*(exp(j*2*pi*ref_p/1024));
end;
if WITH_GAIN_REF == 1
[ref_c ref_p ref_a] = getRefGain(ofdm_params, ofdm_spec_occ, sym_count);
bins = c2i(N, ref_c);
X(bins) = ref_a.*(exp(j*2*pi*ref_p/1024));
end;
if WITH_FREQ_REF == 1
[ref_c ref_p ref_a] = getRefFreq(ofdm_params.mode);
bins = c2i(N, ref_c);
X(bins) = ref_a.*(exp(2*pi*i*ref_p/1024));
X(bins) = ref_a.*(exp(j*2*pi*ref_p/1024));
end;
X(c2i(N, 0)) = 0;
% Modulate
xu = conj(k_fft*ifft(X, N)');
xu = k_fft*ifft(X, N).';
if WITH_RCWIN == 1
x_prefix(1,:) = xu(N-Ng+1:N);
x_suffix(1,:) = xu(1:Ng);
@@ -96,9 +96,13 @@ for k=1:N_frames
xv = [xv xs(1:Ng+N)];
if (DO_PLOT == 1)
Xs = fftshift(fft(xs(Ng+1:Ng+N), N)/k_fft);
plot(0:N-1, abs(Xs(1:N)), '-*'); grid;
pause(0.01);
% Xs = fftshift(fft(xs(Ng+1:Ng+N), N)/k_fft);
Xs = fftshift(X);
subplot(2, 1, 1)
plot(0:N-1, abs(Xs(1:N)), '-*'); grid; axis([0 N-1 0 2]);
subplot(2, 1, 2)
plot(0:N-1, angle(Xs(1:N)), '-*'); grid; axis([0 N-1 -2*pi 2*pi]);
pause(plot_speed);
end
end;
end;