how to determine a period for sinewave

99 views (last 30 days)
Amogelang
Amogelang on 25 Oct 2013
Commented: 2one on 5 Jun 2014
i have been able to generate a sine wave now i want to find its period using matlab, how do i accomplish that?

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 25 Oct 2013
Example
t=0:0.01:10;
y=sin(t);
[idx,idx]=findpeaks(y);
T=t(idx(2))-t(idx(1)) % The periode T (sec)
  1 Comment
2one
2one on 5 Jun 2014
practically this is unlikely to work (when noise is factored in)

Sign in to comment.


Wayne King
Wayne King on 25 Oct 2013
Edited: Wayne King on 25 Oct 2013
You can use fft() as one way. Here's an example with a 100-Hz sine wave (sampled at 1 kHz).
Fs = 1000; % sampling rate
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t);
xdft = fft(x);
[maxval,idx] = max(abs(xdft));
freq = (Fs*(idx-1))/length(x)
Therefore the period is 1/freq

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!