MATLAB: How to convert pressure versus time to pressure versus frequency using fft function

fftfrequency domain

I have tried to convert pressure versus time data to pressure versus frequency using FFT function
This is the pressure versus time signal
after using fft
deltaT=2.5e-6;
fs=1/deltaT;
pxx0 = fft(p);
n = length(p); % number of samples
f = (0:n-1)*(fs/n); % frequency range
mag=abs(pxx0);
figure(1)
semilogx(f,mag)
ylabel ('magnitude');
xlabel ('frequency');
This is the output of FFT function
How to convert the magnitude of FFT to corresponding pressure value like this graph ? in form of pressure versus frequency

Best Answer

  • set xlim between 30 and 1e6
  • set you xtick as [30 300 3e3 3e4 3e5]
  • turn off xMinorTick
  • turn off xMinorGrid
  • turn on grid
  • change linewidth to 1.5
Although it looks like window is also applied on the pressure data and fft size is also greater than the size of signal (next2pow is used)