How i find period and frequency of signal

17 vues (au cours des 30 derniers jours)
Yossi Benyakar
Yossi Benyakar le 21 Avr 2016
Réponse apportée : Baltam le 21 Avr 2016
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?

Réponse acceptée

Baltam
Baltam le 21 Avr 2016
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]')

Plus de réponses (0)

Catégories

En savoir plus sur Signal Processing Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by