fft, problem in determining sampling frequency

조회 수: 9 (최근 30일)
Ata
Ata 2013년 2월 19일
Does Matlab have a default sampling frequency for fft function? how can I change it? I mean when i use
A = abs(fft(thesignal));
plot(A);
the x-label is time!! what does it mean? I also tried determining the frequency and then plotting A by the frequency that I-myself- determined that. it works, but it doesn't make sense. because I can change the frequency axis's magnitudes! and the y axis (Amplitude spectrum) is constant... so for a same frequency on the x axis, I'll give different amplitude!! Thanks for reading...

답변 (2개)

Wayne King
Wayne King 2013년 2월 19일
Azzi is correct in his characterization of the default x-axis. The values that you are getting with your code:
A = abs(fft(thesignal));
plot(A);
Are magnitudes associated with frequencies of the form (2*pi*k)/N radians/sample (or k/N cycles/sample) where N is the length of the input signal, and k = 0,1,2,...N-1
Note that the first value is associated with k=0 which corresponds to a frequency of 0 radians/sample, or DC.
Also, keep in mind that discrete frequencies only increase in oscillation up to a point, and then actually start to decrease.
For an even length, N, at k=N/2, the radian frequency is pi radians/sample. Clearly this has a period of 2 samples.
However at k = 3N/4 (provided that is an integer), the radian frequency is 3pi/2 radians/sample and that has a period of 4 samples.
For a real-valued signal, you can choose to plot the output of fft() (the DFT) for only 1/2 the values so you can obtain an easier to interpret plot where the frequency actually increases monotonically.
You can also use fftshift, if you prefer to visualize 0 frequency at the center of the output.
Ex:
n = 0:159;
x = cos(pi/4*n); % pi/4 radians/sample
xdft = fft(x);
N = length(x)
k = 0:N-1;
plot(k,abs(xdft))
Note that peaks at k=20 and k=140 (which is N-k). k=20 is equal to a radian/frequency of (2*pi*k)/N or pi/4 radians/sample (1 cycle/8 samples)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 19일
편집: Azzi Abdelmalek 2013년 2월 19일
There is no default sampling frequency for fft function. You provide your samples without specifying your sample time, and fft function calculate the discrete Fourier transform of your discrete signal.
in plot(A) there is no x-axis specified. Then by default the x-axis is 1:numel(A), which does not represent neither time, neither frequency. It's just indices
You have to calculate your frequencies data from the sample time of your data a
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2013년 2월 20일
편집: Azzi Abdelmalek 2013년 2월 20일
Try my submission to get your frequencies:
[wc,w0,a0,ak,bk,c0,ck]=get_harmonics(y,pas)
stem(wc,abs(ck))
%y: your signal
% pas your sample time
%The result wc is in rad/s

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

카테고리

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