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

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 commentaires

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,'--')
I do not understand your answer?in my case if i got the results as magnitude domain, how can i convert it to pressure?

Connectez-vous pour commenter.

 Réponse acceptée

Mehmed Saad
Mehmed Saad le 23 Avr 2020
Modifié(e) : Mehmed Saad le 23 Avr 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 commentaires

the x-axis is in log scale
it is related to editing?i am asking about converting the p(f) to corresponding pressure value?
so i was expecting to have at frequency of 100 Hz, pressure magnitude of 0.752 like the last figure, i mentioned.
t=2.5e-6:2.5e-6:0.2;%time
R=0.1;% radius of sphere
f=100;% freq. of velocity
u0=0.01;%amplitude of velocity
U=u0.*sin(2*pi*f.*t);%velocity
c=100;% sonic speed
rho=14.1855;%density
w=2*pi*f;
k=w/c;
r=1;%location of reciever
A=(-1i*w*rho*u0*R^2)/(r*(1-1i*k*R));
p=A*exp(1i*(r-R));
pmag=abs(p);
pReal=real(pmag.*exp(-1i.*(w.*t-65*pi/180)));
pReal=pReal';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%plotting%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1);
%plot(t,pReal,'r',t1,p1,'k')
plot(t,pReal,'r');
xlabel('time (sec)');
ylabel ('pressure (N/m^2)');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%FFT%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
deltaT=2.5e-6;
Fs=1/deltaT;
L = length(pReal); % number of samples
n = 2^nextpow2(L);
Y = fft(pReal,n);
f = Fs*(0:(n/2))/n;
Pp = abs(Y/n);
figure(2)
semilogx(f,Pp(1:n/2+1))
ylabel ('magnitude');
xlabel ('frequency');
deltaT=2.5e-6;
Fs=1/deltaT;
L = length(pReal); % number of samples
n = 2^nextpow2(L);
Y = fft(pReal,n);
f = Fs*(1:n)/n;
Pp = abs(Y/L*2);
figure(2)
semilogx(f,Pp,'LineWidth',1.5)
xlim([30 1e6])
grid on
a = gca;
a.XTick=[30 300 3e3 3e4 3e5];
a.XMinorGrid = 'off';
a.XMinorTick = 'off';
ylabel ('magnitude');
xlabel ('frequency');
zein
zein le 23 Avr 2020
Modifié(e) : zein le 23 Avr 2020
Thanks a lot for your help.
I have run it and i got the same results you post, but i want to ask you a question
why the peak value if i change the time 0:2.5*e-6:0.1? instead of 0:2.5e-6:0.2
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?
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)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by