How to use FFT on my acceleration data in Matlab?
23 views (last 30 days)
Show older comments
Sam Osborne
on 22 Nov 2022
Commented: Star Strider
on 23 Nov 2022
Hello, in a bit of pinch here. I have a single-axis acceleration dataset collected at 100 Hz and wish to perform an FFT on it. The dataset contains one column of acceleration values and one column of time values. I've attached an example of this data in an excel workbook.
I am quite new to this. While I have a fundamental understanding of what FFT does, I can't figure out how to implement it using this data or if this is even possible/useful.
I would like to perform an FFT, filter out some frequencies, and replot the filtered data in the time domain. Any help would be greatly appreciated, thank you!
0 Comments
Accepted Answer
Star Strider
on 22 Nov 2022
Try something like this —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1203773/example.xlsx', 'VariableNamingRule','preserve')
Acc = T1{:,1};
t = T1{:,2};
Fs = 1/(t(2)-t(1));
Fn = Fs/2;
L = size(t,1);
NFFT = 2^nextpow2(L);
FTAcc = fft(Acc-mean(Acc),NFFT)/L;
Fv = linspace(0, 1, NFFT/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTAcc(Iv))*2)
grid
xlabel('Frequency')
ylabel('Maagnitude')
title('Fourier Transform of Acceleration Data')
Your intent to ‘filter out some frequencies’ can be done in a relatively straightforward way.
There are a number of filtering functions such as bandstop (and related functions) that you can use for this, although the signal appears to be relatively ‘clean’. It would be nice to have more details.
.
4 Comments
More Answers (0)
See Also
Categories
Find more on Downloads in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!