how to determine a period for sinewave
109 次查看(过去 30 天)
显示 更早的评论
i have been able to generate a sine wave now i want to find its period using matlab, how do i accomplish that?
0 个评论
回答(2 个)
Azzi Abdelmalek
2013-10-25
Example
t=0:0.01:10;
y=sin(t);
[idx,idx]=findpeaks(y);
T=t(idx(2))-t(idx(1)) % The periode T (sec)
Wayne King
2013-10-25
编辑:Wayne King
2013-10-25
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!