Find frequency from fourier transform

I have the following code which generates a sine wave of frequency 30Hz:
num_sam =1000; %number of samples
sam_int = 0.001; %sample interval in seconds
time = sam_int*(1:num_sam); %sample times, in sec's
sin_freq = 30; %in hertz
y = exp(1i*sin_freq*time);
I'd like to perform a Fourier transform of this wave to find the frequency, but every graph I get isn't peaking (if at all) at 30Hz. How can I achieve this?
Thanks.

1 件のコメント

Adam
Adam 2017 年 1 月 17 日
Have you looked at
doc fft
? There are examples of how to do this.

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

回答 (1 件)

Honglei Chen
Honglei Chen 2017 年 1 月 17 日

0 投票

The signal should be defined as
exp(1i*2*pi*sin_freq*time)
Otherwise, your frequency is scaled by 2*pi.
HTH

質問済み:

2017 年 1 月 17 日

回答済み:

2017 年 1 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by