how to convert pressure versus time to pressure versus frequency using fft function

16 views (last 30 days)
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
  2 Comments
BALAJI KARTHEEK
BALAJI KARTHEEK on 23 Apr 2020
u should scale the pressure and frequency axis to get what u wanted for i need the pressure data or i can given an of how to convert the pressure and frequency axis. Good luck. if you want any help you can free to contact me
%T18EE009 D J K S S BALAJI
%DETERMINE THE MAGNITUDE OF FUNDAMENTAL SIGNAL OF SINUSODIAL AFTER USING FOURIER TRANSFORM
%INPUT DATA
clc
clear all
f=50;%frequency
FM=50;%FREQUENCY TO OBTAINED
T=0.2;%TIME OF THE SIGNAL
N=1024;%NO OF SAMPLES
S=0.02/N;%SAMPLE TIME
fs=1/S;%SAMPLING FREQUENCY
t=0:S:T-S;%timeinterval
O=30*(pi/180);%phase angle
X=200;%MAGNITUDE
for j=1:N*(T/0.02)
x1(1,j)=0;
end
for k=1:20
A=(X/k)*sin((2*3.141*k*t*f)+(O));%CREATION OF HARMONICS
x1=A+x1;
end
t1=1;
t2=0;
for i1=1:(T/0.02)
for i=t1:t1+N-1
A(1,i-t2)=x1(1,i);
end
y=fft(A);%APPLYING FFT
c=abs(y);%CONVERTING COMPLEX VALUES TO ABSOLUTE VALUES
Q=2*c/N;%CONVERSION OF SAMPLING DOMAIN TO MAGNITUDE DOMAIN
B1=(FM*N/fs)+1;%OBTAINING THE FUNDAMENTAL FREUENCY FROM BINS
op(i1)=Q(1,B1);%OBTAINING FUNDAMENTAL MAGNITUDE FROM FFT
ph(i1)=angle(y(1,B1))*(180/pi)+90;
t1=t1+N;
t2=t2+N;
end
t5=0.02:0.02:0.2;
yyaxis left
plot(t5,op)
yyaxis right
plot(t5,ph,'--')
zein
zein on 23 Apr 2020
I do not understand your answer?in my case if i got the results as magnitude domain, how can i convert it to pressure?

Sign in to comment.

Accepted Answer

Mehmed Saad
Mehmed Saad on 23 Apr 2020
Edited: Mehmed Saad on 23 Apr 2020
  • 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)
  8 Comments
zein
zein on 23 Apr 2020
how you change the equations for n and Pp ?
Is there any reference? i do not know how you adjust these equation to give the correct results?
I do not understand how you modify them?
Mehmed Saad
Mehmed Saad on 23 Apr 2020
Edited: Mehmed Saad on 23 Apr 2020
fs = 1000;
t = 0:1/fs:1-1/fs;
s = exp(2j*pi*10*t);
L = length(s);
n = 2^nextpow2(L);
Y = fft(s,n);
Pp = abs(Y)/L;
figure,plot(Pp)
s = real(s);
Y = fft(s,n);
Pp = abs(Y)/L;
figure,plot(Pp)
Pp = abs(Y)/L*2; % because we take fft of real componnet only
figure,plot(Pp)

Sign in to comment.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!