Files
matlab/ofdm/ofdm_rx.m
T
jens 0fd40e13b2 - Introduce frequency offset
git-svn-id: http://moon:8086/svn/matlab/trunk@8 801c6759-fa7c-4059-a304-17956f83a07c
2014-07-29 18:04:01 +00:00

27 lines
661 B
Matlab

function ofdm_rx(x)
close all;
CP_SIZE = 256;
FFT_SIZE = 1024;
fa = 48000;
fo = 0.0;
k_fft = 2*sqrt(FFT_SIZE);
% Introduce frequency offset
x = 0.5*exp(i*2*pi.*(0:length(x)-1)*fo/fa)' .* x;
figure;
Ns = (CP_SIZE + FFT_SIZE);
Nf = length(x)/Ns;
for k=1:Nf
Xs = fft(x((k-1)*Ns+CP_SIZE+1:(k-1)*Ns+CP_SIZE+FFT_SIZE), FFT_SIZE)/k_fft;
mag = abs(Xs(1:FFT_SIZE/8));
phase = angle(Xs(1:FFT_SIZE/8));
subplot(2, 1, 1)
plot(fa*(0:lge(mag)-1)/FFT_SIZE, mag, '-*'); grid;
subplot(2, 1, 2)
plot(fa*(0:lge(phase)-1)/FFT_SIZE, phase, '-*'); axis([0, fa*(lge(phase)-1)/FFT_SIZE, -pi, +pi]);grid;
pause (0.001);
end