how to convert pressure versus time to pressure versus frequency using fft function
12 次查看(过去 30 天)
显示 更早的评论
I have tried to convert pressure versus time data to pressure versus frequency using FFT function
This is the pressure versus time signal
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286787/image.jpeg)
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286788/image.jpeg)
How to convert the magnitude of FFT to corresponding pressure value like this graph ? in form of pressure versus frequency
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286789/image.jpeg)
2 个评论
BALAJI KARTHEEK
2020-4-23
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,'--')
采纳的回答
Mehmed Saad
2020-4-23
编辑:Mehmed Saad
2020-4-23
- 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 个评论
Mehmed Saad
2020-4-23
编辑:Mehmed Saad
2020-4-23
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286858/image.png)
figure,plot(Pp)
s = real(s);
Y = fft(s,n);
Pp = abs(Y)/L;
figure,plot(Pp)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286859/image.png)
Pp = abs(Y)/L*2; % because we take fft of real componnet only
figure,plot(Pp)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/286862/image.png)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!