How do I plot the FFT of signal from accelerometer

조회 수: 42 (최근 30일)
tje_b
tje_b 2022년 8월 6일
댓글: William Rose 2022년 8월 7일
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) ?

채택된 답변

William Rose
William Rose 2022년 8월 6일
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
William Rose
William Rose 2022년 8월 7일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

William Rose
William Rose 2022년 8월 6일
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
tje_b
tje_b 2022년 8월 6일
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 2022년 8월 7일
The script I posted in the comment below computes the FFT of all three components. It also plots all three components.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by