# Vibration Analysis by using FFT

I have 6 column vectors $(\mathbf A_x,\mathbf A_y, \mathbf A_z, \mathbf G_x, \mathbf G_y, \mathbf G_z)$ taken by accelerometer to analyze the vibration of a construction. Each column is a $64998\times 1$ valued-vector and overall time is $664$ seconds. I've done something but I don't know how I can fix it.

Fs=97.885;
L=64998;
NFFT=2^nextpow2(64998);

AXdft = fft(Ax);
AXdft=AXdft(1:NFFT/2+1,:);

freq = linspace(0,Fs,NFFT/2+1);

plot(freq,2*abs(AXdft));
xlabel('Hz');ylabel('Magnitude');

figure;
plot(freq,20*log10(abs(AXdft)));
xlabel('Hz');ylabel('dB');
title('Plot in dB');

BTW I will add each column over other via hold on

getting a figure but missing its size. The frequency doesn't appear in figure and I guess I must do PSD, Can anyone help?

## 1 Answer

I believe that your problem is using nextpow2 to set the fft length. fft(x) returns a vector length(x). fft(x) is not constrained to a power of 2. If you want to set a particular size by zero padding, use fft(x,N). NFFT=length(Ax) is the actual size of DFT.

Using psd has advantages but if you use the proper size, your code will work (assuming I am correct) . Taking a single long DFT isn't an accepted way to estimate a psd, unless you are looking for very fine, high snr features.

• Thanks for your care, i've tried and used only L instead of using NFFT. The code creates a figure where data doesn't appear. I think, it doesn't encompass because of axis(x or y) that can't be fixed with 'axis' command. Scaling it 1/64998 sounds well but doesn't work. What I miss here. ( By the way Ax is a column vector and has 64998x1 value) – huytergan Aug 4 '17 at 22:10
• Matlab takes a very long time to render 65,000 points. Your display doesn't nearly have the pixels to render the data. Break up your data in 2048 point segments Don't use hold on until you get something to work. Think about the constraints of your display – user28715 Aug 4 '17 at 22:19
• just tried that you said.I don't think that's the reason it doesn't show anything. – huytergan Aug 4 '17 at 22:45
• MATLAB doesn't render NaN values. Look at your numbers. – user28715 Aug 4 '17 at 23:01
• thx there was some NaN data and i fixed them, but MATLAB has still been returning NaN values when I try to access 'abs(AXdft)', the whole numbers which taken by accelerometer in excel, are real numbers. – huytergan Aug 5 '17 at 13:24