Acceleration vs Time data into FFT

I have acceleration vs time data. I want to get FFT value from the data.Can someone show me the way?

 Accepted Answer

spectrum = fft(signal);

8 Comments

I have tried the given coding but the value is an unreasonable. Can you suggest another coding?
Why do you say it's unreasonable? Maybe you want to use pwelch() in the Signal Processing Toolbox instead. There is a webinar about spectral processing that covers pwelch.
Attached is the figure when I am using the given code. Maybe you can tell me why.Or do i need further coding since you said your code and Shoaibur are essentially the same or very similar code. Please enlighten me.Thank you.
Image Analyst
Image Analyst on 18 Jan 2015
Edited: Image Analyst on 18 Jan 2015
Why are you getting a signal like that for my code and a 1D signal for Shoaibur's? It doesn't make sense to me. Please attach your data and code so I can see how you got the plot here, and the plot in Shoaibur's answer. Did you call plot in the same way for both of them? Like plot(abs(y))???
Ok.Attached excel data sheet.Just use time diff column for time history and ch1 for acceleration respond.
Here the coding for your code
spectrum = fft(signal);
>> plot(spectrum)
While shoaibur's is:
signal = CH1;
N=7574;
t=Time;
% Plot Original signal in Time Domain
subplot(211), plot(t,CH1);
title('Original signal in Time Domain');
xlabel('Time [s]');
ylabel('Acceleration [m/s^2]');
% Plot FFT signal
N = pow2(nextpow2(length(signal)));
y = fft(signal,N);
subplot(212),plot(1:N,abs(y));
title('FFT');
xlabel('Frequency [Hertz]');
ylabel('Magnitude');
Hope you can solve it.Really appreciate your concern.
How are you reading in the workbook? With xlsread()? And why did you plot the absolute value of his "y", but not for my "spectrum"? The fft will be complex in general so you should plot the real, imaginary, or magnitude of the spectrum.
I import the data into matlab. Thats means the coding should be spectrum = fft(signal); plot(1:N,abs (spectrum));
Is it true??
I got the FFT value from your coding image analyst.Is the bandwidth of FFT data according to my time history domain data?If not,how to ensure the bandwidth is within the interval?Can you brief me about the coding? My bandwidth range is 50Hz-500Hz from time domain history data.

Sign in to comment.

More Answers (1)

Define the number of DFT points N, and then perform the fft.
N = pow2(nextpow2(length(signal)));
y = fft(signal,N);
plot(1:N,abs(y))
If the length of your signal is a big number then set the value of N manually to a lower value, like N = 64, 128, 256, etc. This will make your figure to look better sometime, but note that that may not be accurate always from the computational point of view.

8 Comments

Thank you so much.You are helping me out.Solve.
But, can I ask another question. I have x,y,z signal.How to plot it in 1 graph?I mean the FFT value.How to use the coding repeatedly but with different signal?
Kirthi Devleker
Kirthi Devleker on 17 Jan 2015
Edited: Kirthi Devleker on 17 Jan 2015
You can watch "Spectral Analysis with MATLAB" webinar. Your question about plotting the FFT value is answered there
How is this helping? It's the same as the code I gave you and you said it was unreasonable. Except his code somehow changes the length of the signal to a power of 2 which is not necessary.
nur yusof
nur yusof on 18 Jan 2015
Edited: Image Analyst on 18 Jan 2015
The figure is unreasonable.The FFt should be around two or three digit. Please look at the figure i attached.Can someone tell me why
I don't know what 2 or 3 digits means in this context. And it doesn't look unreasonable to me.
I still say my and Shoaibur's code are essentially the same or very similar code. So show the results of Shoaibur's code and tell me how it helped you solve it.
By the way, you might want to call fftshift().
Attached previous figure is solve by Shoaibur's coding. While, attached figure solve by image analyst.I dont know why the figure look like that.I think the frequency solve by Shoaibur is high maybe due to the the vibration of bridge,vehicle and noise from environment.So, it has high value.
I got the FFT value from the coding.Is the bandwidth of FFT data according to my time history domain data?If not,how to ensure the bandwidth is within the interval?Can you brief me about the coding? My bandwidth range is 50Hz-500Hz from time domain history data.

Sign in to comment.

Categories

Find more on Fourier Analysis and Filtering 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!