How to Show A OFDM Symbol's PSD in Matlab - Signal Processing Stack Exchange most recent 30 from dsp.stackexchange.com 2019-11-12T18:20:06Z https://dsp.stackexchange.com/feeds/question/13144 https://creativecommons.org/licenses/by-sa/4.0/rdf https://dsp.stackexchange.com/q/13144 0 How to Show A OFDM Symbol's PSD in Matlab rayoung https://dsp.stackexchange.com/users/7235 2013-12-12T04:54:20Z 2017-02-01T02:42:38Z <p>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. <img src="https://v1.freep.cn/3tb_131216204513jmi1512293.jpg" alt="OFDM spectrum"> <img src="https://v1.freep.cn/3tb_131216210025u6ku512293.jpg" alt="spectrum 2"></p> <p>My matlab code:</p> <pre><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))); </code></pre> <p>The figure is like this <img src="https://v2.freep.cn/3tb_131216215821pewb512293.jpg" alt="spectrum 3"></p> https://dsp.stackexchange.com/questions/13144/-/13160#13160 1 Answer by Jim Clay for How to Show A OFDM Symbol's PSD in Matlab Jim Clay https://dsp.stackexchange.com/users/923 2013-12-12T21:04:02Z 2013-12-12T21:04:02Z <p>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)-</p> <pre><code>plot(20*log10(abs(fft(dataVector)))) </code></pre> <p>or, to center the FFT visually-</p> <pre><code>plot(fftshift(20*log10(abs(fft(dataVector))))) </code></pre> https://dsp.stackexchange.com/questions/13144/-/13233#13233 1 Answer by Deve for How to Show A OFDM Symbol's PSD in Matlab Deve https://dsp.stackexchange.com/users/1606 2013-12-17T09:58:55Z 2013-12-17T09:58:55Z <p>I see two differences between your PSD plot and those from the reference you have given</p> <ol> <li>The PSD is normalized to the mean power of the data subcarriers</li> <li>The PSD is "smoother"</li> </ol> <p>In order to obtain a similar result</p> <ol> <li>Calculate the mean of the PSD at the data subcarriers and divide the PSD by this value</li> <li>"Bin" your PSD, i. e. take the mean of every \$N\$ PSD values to create a "smooth" version of the original PSD</li> </ol> <p>By adding the following lines to your code...</p> <pre><code>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'); </code></pre> <p>...I've created the following plot...</p> <p><img src="https://i.stack.imgur.com/mWyv2.png" alt="PSD of OFDM signal"></p> <p>...which I think looks quite similar to your references.</p>