How can I keep the values passed through the fft the same?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I have a list of 500000 data points taken from an accelerometer with a sampling frequency of 100000 Hz for 5 seconds and I wish to pass it through an FFT to see it's frequency response and later calculate it's PSD. I've done some reading around and managed to write my own code and this is what I came up with. This is intended to be a vibration analysis so that we can find the natural frequency of the metal pipe we are testing.
Fs = 100000;%sampling frequency
DATA = xlsread('FFTData 1.xlsx');%reading data in from excel file
t = DATA(:,1);%time values from DATA file in Second's
x = DATA(:,4);%Acceleration values read from DATA file in G's
L=length(x);%the number of values read from the data file (500000)
NFFT = 2^nextpow2(L);%better fft makes zero padding.
Y = fft((x - mean(x)),NFFT);%fourier transform of the signal subracting DC Bias Voltage
%Also need to specify NFFT, if we don't, fft() defaults to 512 points
f = Fs/2*linspace(0,1,NFFT/2+1);%span of frequency we want to run through, all the way up to NFFT %value
figure(1);
plot(t,x);%plotting time vs. acceleration
title('Drop Shock Test 1');
xlabel('Time (s)');
ylabel('Acceleration (G''s)');
figure(2);
plot(f,abs((Y(1:NFFT/2+1)))/L);%plotting frequency vs. acceleration. FFT is in Volts*Seconds.
title('Drop Shock Test 1 FFT');
xlabel('Frequency (Hz)');
ylabel('Acceleration (G''s)');
h = spectrum.welch; % Create a Welch spectral estimator.
Hpsd = psd(h,x,'Fs',Fs); % Calculate the PSD
figure(3);
plot(Hpsd)
My question is, is there a way to get the same y-axis values seen in figure (1), to appear on the y-axis in figure (2) in the frequency domain? I'm also new to asking questions on here (first timer) and I'm not very sure how to attach a file with data points or pictures.
Thanks, Brandon Deal
0 commentaires
Réponse acceptée
Matt J
le 11 Juin 2013
Modifié(e) : Matt J
le 11 Juin 2013
You can use ylim() to control the y-axis limits. However, I don't see how it makes sense to have them the same. Since one is a time-domain plot and the other a frequency domain plot, the quantities plotted are completely different in nature. Why expect them to have the same range of values?
9 commentaires
Matt J
le 11 Juin 2013
I'm saying I don't know what Y is trying to measure. If it is supposed to be approximating the continuous Fourier transform of your data, you would do this
dt=t(2)-t(1); %time sampling interval
Y = fft((x - mean(x)),NFFT) * dt;
However, only you know what you want. There are many applications of FFTs besides approximating continuous Fourier spectra.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!