How do I plot the FFT of signal from accelerometer

43 visualizzazioni (ultimi 30 giorni)
The Sample rate of the accelerometer from the arduino IDE was 833Hz and I placed the accelerometer on a shaker, The shaker has an input frequency of 200Hz and amplitude of 3Vpp in 13s. The data generated was recorded in .CSV as attached.
Can anyone help with the FFT code using either the X-axis(First column) or Y-axis data(Second column) ?

Risposta accettata

William Rose
William Rose il 6 Ago 2022
Try the code below. It makes the figure below.
The figure shows that the oscullaiton frequency was not exactly 200 Hz. Or the sampling rate was not really 833 Hz.
Good luck.
  1 Commento
William Rose
William Rose il 7 Ago 2022
I forgot to include a legend. I recommend adding the line
legend('ax','ay','az');
to the script, after each of the two plot commands.
If the sampling rate is 1000 Hz, rather than 833 as you said in the original post, then the two large peaks in the spectrum occur at 200 and 400 Hz, consistent with your statement that the shaker was shaking at 200 Hz. See figure below, in which I changed fs to 1000 in the script. I also added the legend() statements.

Accedi per commentare.

Più risposte (1)

William Rose
William Rose il 6 Ago 2022
Sampling rate is fs=833 Hz and there are N=1110 samples. (I deleted line 1 since it has only one number.)
When you do the FFT, you get a vector of N complex numbers. The first N/2+1 of those numbers correspond to frequencies 0:df:Fs/2, where df=fs/N.
Plot the amplitudes of the first N/2+1 elements of the FFT, versus the frequecies as described above.
  2 Commenti
tje_b
tje_b il 6 Ago 2022
Many thanks for the swift response.
@William Rose,I have few question and I would appreciate if the answers are simplified as I am a beginner.
1) Is the code for the entire signal or the first colume only?
2) Can you help with the code
William Rose
William Rose il 7 Ago 2022
The script I posted in the comment below computes the FFT of all three components. It also plots all three components.

Accedi per commentare.

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by