I would like to count the number of peaks of a signal.
41 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
mohamed ali
am 25 Feb. 2023
Kommentiert: Star Strider
am 26 Feb. 2023
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![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1306665/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1306665/image.png)
0 Kommentare
Akzeptierte Antwort
Star Strider
am 25 Feb. 2023
Bearbeitet: Star Strider
am 25 Feb. 2023
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 Kommentare
Weitere Antworten (2)
Askic V
am 25 Feb. 2023
Bearbeitet: Askic V
am 25 Feb. 2023
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))
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 :)
0 Kommentare
Image Analyst
am 25 Feb. 2023
In addition to findpeaks, if you don't have the Signal Processing Toolbox, you can use islocalmax in base MATLAB.
0 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!