I would like to count the number of peaks of a signal.
42 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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 个)
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!