# MATLAB - How do I get the Filter Function to get the output Energy Spectrum? The image was from a question I posted on reddit, so ignore the title.

I'm trying to write a program that plots these graphs

weird fft plot of source signal - me - a female just saying "aaaaahhhh" for about 15 seconds

And after I get the right filter function, I do conv??

Thanks in advance.

• You need to take the magnitude of the spectrum 'abs(fft(x))' before plotting. – Harris Mar 28 at 22:30
• @Harris noted. - thanks – ThermoRestart Mar 29 at 17:28

## 2 Answers

What u plotted is the complex fft samples. In order to see the psd in matlab use plot([-1/2:1/ffteln:1/2-1/fftlen]*fs, 10*log10( abs( fftout)./length(fftout)).^2)). I am assuming of coarse that your signal is real and therefore plotting from -fs/2:fs/2 is standard practice. For complex signals usually you want to plot from 0:Fs because nyquist is Fs for complex.

• Thanks for your response to my question! I was told that the 3rd figure plot is a plot of the spectral density, and that periodogram(y_source) will gives the plot of the output spectrum density. – ThermoRestart Mar 29 at 17:28

The output plot is a plot of the power spectural density. Matlab has built in functions that run estimates of this. psd has deprecated, however, periodogram(sourcesignal) will give the output spectrum density plot, bypassing the need to create a filter function signal for modulation.