how can find frequency from an fft function?

조회 수: 35 (최근 30일)
mrkovi
mrkovi 2015년 11월 22일
편집: Ullah Nadeem 2022년 3월 18일
hi, I'm doing a coupled oscillators experiment involving two measured angles changing over time. i imported the data -csv - with one column (867x1) for each variable; time, angle 1, angle 2.
when i enter: plot(abs(fftshift(fft(Y1)))); (where Y1 = the column vector for angle 1.) i am unsure of the meaning of the figure that is produced, specifically the numbers on the x axis.
i have been told that the y axis is the amplitude and that the x axis is the index, but i do not understand how i am meant to understand the frequency of the oscillation from these two things.
additionally every post i have found connected to this problem refers to the following equation: Frequency = i * (Fs/N)
am i correct in assuming that "i" is the x coordinate? that N is 867? and Fs i am entirely confused as to how to calculate.
i have attached the figure, please advise.

답변 (3개)

Rick Rosson
Rick Rosson 2015년 11월 23일
편집: Rick Rosson 2015년 11월 23일
Fs = 40; % samples per second
N = length(Y1); % samples
dF = Fs/N; % hertz per sample
f = -Fs/2:dF:Fs/2-dF + (dF/2)*mod(N,2); % hertz
Y1_fft = fftshift(fft(Y1))/N;
figure;
plot(f,abs(Y1_fft));
  댓글 수: 1
Ullah Nadeem
Ullah Nadeem 2022년 3월 18일
편집: Ullah Nadeem 2022년 3월 18일
Hello Rick!
Hope you're fine, I guess dF = Fs/N is hertz {(samples per sec)/(samples) = 1/sec = hertz} not hertz per sample, hertz per sample would be dF/N. Please correct me if I'm wrong...
Thank you!

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


Guillaume
Guillaume 2015년 11월 22일
It sounds like you're lacking the basics of fourier transform analysis. You would probably better off learning about it before trying to apply it.
Yes, i is your sample number, your x, axis. N is the number of sample (usually you try to make it a power of 2). Fs is your sampling frequency. You must have acquired your measurement at a fixed frequency.
  댓글 수: 2
mrkovi
mrkovi 2015년 11월 22일
i understand that i'm lacking the basics Guillaume, i'm a first year physics student thrown into an advanced physics lab. the data was acquired by an electronic sensor that measured the movement of the oscillation... if i look at the csv, it appears for every 1.00 seconds that passes, 40 measurements were taken i.e. every 0.025 seconds... pardon my ignorance but how do i get the sampling frequency from that?
Guillaume
Guillaume 2015년 11월 23일
Your sampling frequency is thus 40 Hz (40 samples per second).

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


Star Strider
Star Strider 2015년 11월 22일
The current R2015b documentation is confusing (at least in my opinion). See the R2015a documentation for fft for a more appropriate implementation. The only correction that needs to be made to the code between the first two plot figures is to multiply the result of the fft by 2 with a one-sided fft.
This will give the correct amplitudes:
Y = fft(y,NFFT)*2/L;

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by