how to determine a period for sinewave
109 views (last 30 days)
Show older comments
i have been able to generate a sine wave now i want to find its period using matlab, how do i accomplish that?
0 Comments
Answers (2)
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
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
0 Comments
See Also
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!