Clear Filters
Clear Filters

FFT of acceleration data?

1 view (last 30 days)
Careniena Opem
Careniena Opem on 22 Jun 2021
Answered: Chunru on 23 Jun 2021
I have acceleration data stored as the variable avgacc. I am trying to generate (and smooth) an FFT but having difficulty. Here is my code for the FFT unsmoothed:
Fs = 1000; %sampling rate
L = 2000; %length of data
Y = fft(avgacc);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1);
I attempted a moving average and using sgolayfilt but am pretty lost regarding this step. Any help would be greatly appreciated!

Answers (1)

Chunru
Chunru on 23 Jun 2021
Using fft alone, the spectrum estimate is not smooth.
X = randn(4196, 1);
N = 256;
h(1)=subplot(211); plot(20*log10(1/sqrt(N)*abs(fft(X(1:N)))));
One can use periodogram or pwelch for better spectrum estimate (segment, window, fft and average).
Pxx = pwelch(X,N,N/2,N);
h(2)=subplot(212); plot(10*log10(abs(Pxx)));
linkaxes(h, 'xy')

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!