fft of a signal

2 ビュー (過去 30 日間)
Tina
Tina 2013 年 3 月 29 日
Hello;
I know I have to use fft for getting the fourier transform of a signal, but I am a bit confused here.
I want to have a plot which shows the amplitude of the fourier transform of a signal vs. the frequency. My signal is a 100x1 matrix, and my sampling frequency was 40Hz. What should I do now?

回答 (2 件)

Wayne King
Wayne King 2013 年 3 月 29 日
編集済み: Wayne King 2013 年 3 月 29 日
You have to create a meaningful frequency vector to go along with your Fourier transform.
The spacing for the DFT (discrete Fourier transform) frequencies is Fs/N where N is the length and Fs is the sampling frequency.
Fs = 40;
t = 0:1/Fs:4-1/Fs;
x = cos(2*pi*10*t)+randn(size(t));
xdft = fft(x);
Now to create the frequency vector.
f = 0:Fs/length(x):Fs/2;
You'll see that the length of f is not equal to the length of xdft.
That's because xdft contains both positive and "negative" frequencies.
We only need 1/2 of xdft because the signal is real-valued.
xdft = xdft(1:length(x)/2+1);
plot(f,abs(xdft)); xlabel('Hz');
  2 件のコメント
Tina
Tina 2013 年 3 月 29 日
Thanks but my signal is not something like that you put as x above. My signal is a solution to and ODE, so I dont have the formula for my signal, I just have a matrix now.
Wayne King
Wayne King 2013 年 3 月 29 日
It does not matter, since I don't have your signal, I made an example for you. If you data is sampled at 40 Hz, then you construct the frequency vector the same way.

サインインしてコメントする。


Azzi Abdelmalek
Azzi Abdelmalek 2013 年 3 月 29 日
Example
fs=40
t=0:1/fs:99/fs;
y=rand(1,100);
Yk=fft(y);
N=numel(y)
f=fs*(0:(N-1))/N % frequencies
stem(f,abs(Yk))

カテゴリ

Help Center および File ExchangeFourier Analysis and Filtering についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by