How can I keep the values passed through the fft the same?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Spectral Measurements 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!