필터 지우기
필터 지우기

I would like to count the number of peaks of a signal.

조회 수: 41 (최근 30일)
mohamed ali
mohamed ali 2023년 2월 25일
댓글: Star Strider 2023년 2월 26일
Hello everone,
]I am working with a signal produced from my simulink model and I am doing some analysis on the signal but I dont know how to calculate the number of cycles?
Best regards

채택된 답변

Star Strider
Star Strider 2023년 2월 25일
편집: Star Strider 2023년 2월 25일
Use the signal Processing Toolbox findpeaks function to count the peaks. The plotted signal does not appear to be noisy, so it will likely not be necessary to use other name-value pair arguments (such as 'MinPeakProminence') to define the peaks). (I have no idea if this works with Simulink, since I very rarely use Simulink.)
Just use:
t = ...; % Time Vector
s = ...; % Signal Vector
[pks,locs] = findpeaks(s);
NrPks = numel(pks)
.
  댓글 수: 2
mohamed ali
mohamed ali 2023년 2월 26일
thank you so much, your answer really helped!
Star Strider
Star Strider 2023년 2월 26일
As always, my pleasure!

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

추가 답변 (2개)

Askic V
Askic V 2023년 2월 25일
편집: Askic V 2023년 2월 25일
t = 0:0.01:2;
y = sin(20*t);
[z, ind] = findpeaks(y);
plot(t,y)
hold on
plot(t(ind), z, 'o')
number_cylces = numel(diff(z))
number_peaks = 6
If you need to find number of cycles, you need to fnd the number of peaks first. Matlab has a built in function called findpeaks :)

Image Analyst
Image Analyst 2023년 2월 25일
In addition to findpeaks, if you don't have the Signal Processing Toolbox, you can use islocalmax in base MATLAB.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by