# How to Show A OFDM Symbol's PSD in Matlab

I'm trying to suppress the sidelobe of OFDM but having troubles showing its spectrum in Matlab. After IFFT, I get a time-domain signal, but in which way I can get its spectrum(or PSD)? I want to analyze the out band power emission, with rectangle window in the time domain the out of band power curve decrease slowly, so it may interference the adjacent channel user, to avoid that situation we have to apply some algorithms to suppress the out of band power emission caused by the sidelobe of OFDM signal. After apply the algorithm I have to plot some figures to demo the effect of my algorithm, so I need the whole PSD of OFDM signal and I also want the out of band part become more steep. I tried to use FFT and pwelch function of Matlab, but never get what I want. I doubt if I use them in right way. So I'm hoping someone here can help me. I know it's basic, but it really obsess for a long time. I analyze the baseband signal, so it should be after the IFFT operation.The figure that I want is below.

My matlab code:

  N = 64;
over_sample_factor = 2;
M = N*over_sample_factor;
Mod = 16;
symbol = 1;
bitlength = N*log2(Mod)*symbol;
itr_num = 1000;
fft_len = 2*M;
signal_freq = zeros(itr_num,fft_len);
for itr = 1:itr_num
bit_data = randi([0,1],bitlength,1);
h = modem.qammod('M', Mod, 'SymbolOrder', 'Binary', 'InputType', 'Bit');
zp_before = modulate(h,bit_data);
after_zp = zeros(1,M);
after_zp(1:N/2) = zp_before(N/2+1:N);
after_zp(M-N/2+1:M) = zp_before(1:N/2);
ofdm_symbol = ifft(after_zp);
signal_freq(itr,:) = abs(fft(ofdm_symbol,fft_len)).^2;
end
PSD_mean = mean(signal_freq,1);
plot(fftshift(10*log10(PSD_mean)));


The figure is like this

• What do you want? To see the sidelobes you have to plot the PSD of the "analog" signal, that is to say of an oversampled version of the IFFT output. The PSD will therefore also depend on the pulse shaper you're using. A rectangular impulse is a good start, it models an digital-to-analog converter. – Deve Dec 12 '13 at 7:57
• Thanks, Deve. Do you mean oversampling is essential to plot the PSD? I know oversample means insert '0' in the center of symbols that will be modulated and do a longer ifft, but I don't know why it's been called oversample, it's not like an usual oversample I've learned. And I wonder what oversample ratio is sufficient to plot the PSD. I'm using a rectangle pulse, why do you say it models a DAC? – rayoung Dec 12 '13 at 12:55
• It was not exactly clear to me what you'd like to analyze. Maybe you can rephrase your question. If you directly apply an FFT to the IFFT output you can estimate the spectrum from $-f_s/2$ to $f_s/2$. If you'd like to analyze spectral components beyond that bandwidth you'll have to use a higher sampling frequency, thus my suggestion to apply oversampling. In a complete comm. system, at what point would you like to analyze the OFDM spectrum? – Deve Dec 12 '13 at 15:43
• Deve, I've rephrased my question, I think it's clear this time. – rayoung Dec 16 '13 at 6:07
• Please show us some code snippets and/or figures. Define "whole" PSD - what bandwidth would you like to analyze? At what point in the comm. system would you like to analyze the OFDM spectrum? After IFFT, after DAC, after transmit filter? – Deve Dec 16 '13 at 8:35

If you are looking at the sidelobes in particular then you will probably want to oversample, as Deve mentioned. x2 oversampling should be sufficient, but you can do more if you want. I generally plot my FFT's as follows to get the energy in a dB scale (Matlab syntax)-

plot(20*log10(abs(fft(dataVector))))


or, to center the FFT visually-

plot(fftshift(20*log10(abs(fft(dataVector)))))


I see two differences between your PSD plot and those from the reference you have given

1. The PSD is normalized to the mean power of the data subcarriers
2. The PSD is "smoother"

In order to obtain a similar result

1. Calculate the mean of the PSD at the data subcarriers and divide the PSD by this value
2. "Bin" your PSD, i. e. take the mean of every $N$ PSD values to create a "smooth" version of the original PSD

plot(linspace(-1,1,fft_len), fftshift(10*log10(PSD_mean)));
hold on;

mean_sig_power = mean([PSD_mean(1:N/2) PSD_mean(fft_len-N/2+1:fft_len)]); % mean power of data subcarrierse
PSD_mean = fftshift(PSD_mean);
bin_length = 2;
num_bins = floor(fft_len / bin_length);
PSD_smooth = zeros(1, num_bins);
for k = 1:num_bins
PSD_smooth(k) = mean(PSD_mean((k-1)*bin_length + 1 : k*bin_length));
end
plot(linspace(-1,1,num_bins),(10*log10(PSD_smooth./mean_sig_power)),'r');
hold off;
ylim([-35 12]);
grid on;
legend('yours', 'theirs');


...I've created the following plot...

...which I think looks quite similar to your references.

• Thanks for the post, was of great use to me. Can you indicate some bibliography explaining how to make this kind of application in MATLAB with OFDM too? Thanks. With all regards, Flávio Sampaio – Flávio Sampaio Feb 1 '17 at 2:42

## protected by datageist♦Feb 1 '17 at 7:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).