I'm trying to simulate an OFDM signal that has been captured with a receiver that has a much larger bandwidth than the OFDM signal. I tried the following MATLAB code to simulate an OFDM signal that's 20% of the captured bandwidth and then demodulate it:
Nsymbol = 100; M = 16; Nfft = 128; CPlen = 12; % random bits... in_bits = randi([0 1], log2(M), Nsymbol*Nfft); % use a 16-QAM symbol constellation symbols = qammod(in_bits, M, 'InputType', 'bit'); % reshape it ofdmmod parallel_symbols = reshape(symbols, Nfft, Nsymbol); baseband = ofdmmod(parallel_symbols,Nfft,CPlen); % oversample by a factor of 5 and then decimate by a factor of 5 again oversampled = resample(baseband, 5, 1); back2baseband = resample(oversampled, 1, 5); symbols2 = ofdmdemod(back2baseband, Nfft, CPlen); plot(symbols2(:), '.');
When I run the code, I expect that the symbol constellation should be (roughly) the same as the original 16-QAM constellation, but instead I get this:
As a result, I get a BER of about 1% with no noise in my simulation... clearly I am doing something wrong. What is the right way to demodulate an oversampled OFDM signal in MATLAB? I tried using the DigitalUpConverter and DigitalDownConverter objects as well, but that was a total disaster.
EDIT: Thanks to Dan's answer below, I realized that the filters that MATLAB applies when downsampling induced a linear phase shift so I was looking at the wrong sample. When I just do
back2baseband = oversampled(1:5:end) I recover the ideal constellation.