How i find period and frequency of signal
37 次查看(过去 30 天)
显示 更早的评论
Hi How i find period and frequency of signal
t=-2*pi:0.01:2*pi;
k1=3;k2=1;k3=1;k4=3;k5=7;k6=8;
y=k1*cos(((2*pi)/k2)*t+k3)+k4*cos(((2*pi)/k5)*t+k6);
How i find period?
0 个评论
采纳的回答
Baltam
2016-4-21
Use fourier transform
t=0:0.01:70-0.01; % I chose the maximum time to be a multiple of 7.
% You need to try and fit an exact amount of periods into your signal to
% get good results with fft or otherwise use a very long signal
k1=3;k2=1;k3=1;k4=3;k5=7;k6=8;
y=k1*cos(((2*pi)/k2)*t+k3)+k4*cos(((2*pi)/k5)*t+k6);
% Your periods are going to be k2 and k5
% Sampling frequency
Fs = 1/(t(2)-t(1));
% Calculate fft
ydft = fft(y);
% Only take one side of the Fourier transform
ydft = 2*ydft(1:ceil((length(y)+1)/2));
% Calculate the frequencies
freq = 0:Fs/length(y):Fs/2;
% Normalise according to length of signal
ydft = ydft/(2*length(freq));
figure,
subplot(3,1,1), plot(t,y), xlabel('Time [s]')
subplot(3,1,2), loglog(1./freq,abs(ydft)), xlabel('period [s]')
subplot(3,1,3), loglog(freq,abs(ydft)), xlabel('frequency [Hz]')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!