How to calculate period of signal with matlab

조회 수: 138 (최근 30일)
Ioannis
Ioannis 2014년 11월 30일
편집: OSAMA MOHAMED ALI 2024년 4월 23일
Hi everybody, I have the signal x2(t)=|cos(10*pi*t)|.How can i calculate its period with matlab?I am new matlab so each help will be usefull
  댓글 수: 1
Azzi Abdelmalek
Azzi Abdelmalek 2014년 11월 30일
This is not clear, do you have samples or what?

댓글을 달려면 로그인하십시오.

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 12월 1일
편집: Mohammad Abouali 2014년 12월 1일
use autocorrelation. If your data is periodic you should get high correlation once the lag time matches the period. here is an example:
x=0:0.1:20*2*pi;
y=sin(x); % so we know the period is 2*pi roughly 6.28
ac=xcorr(y,y);
[~,locs]=findpeaks(ac);
mean(diff(locs)*0.1)
ans =
6.2842
In a more complex data set including some noise you need to work around the find peaks a little bit. That might be too noisy.
In the example you gave here is what you will get
x=0:0.01:20*2*pi;
y=abs(cos(10*pi*x));
ac=xcorr(y,y);
[~,locs]=findpeaks(ac);
mean(diff(locs)*0.01)
ans =
0.1000
Another approach is using FFT, particularly if you have a more complex signal.
  댓글 수: 3
Anuj Patel
Anuj Patel 2017년 4월 26일
What is the other FFT approach , sir?
Lucky Moffat
Lucky Moffat 2023년 2월 22일
Take the FFT of the signal, then compute the power spectrum. Then, determine the frequency index k of maximum power. After this, determine the frequency at index k of maximum power. Once you've found the frequency it's easy to find the period since T = 1/f, e.g.,
t = 0:0.004:4;
sig = cos(2*pi*20*t);
a = fft(sig, 1024);
A = abs(a).^2;
[~, index_max_power] = max(A);
index_freq = index_max_power / ((t(2)-t(1))*length(A));
period = 1/index_freq
So, in that example the period T should be closer to 0.05.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Firstname Lastname
Firstname Lastname 2017년 8월 21일
편집: KSSV 2022년 7월 9일
t=0:.01:10;
y=10*sin(10*pi*t);
[idx,idx]=findpeaks(y);
T=t(idx(2))-t(idx(1));
disp(['Time Period =' num2str(T),'seconds']);
  댓글 수: 1
OSAMA MOHAMED ALI
OSAMA MOHAMED ALI 2024년 4월 23일
편집: OSAMA MOHAMED ALI 2024년 4월 23일
can I use it for discrete signals?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by