How make a loop that finds my selected specific peaks and plots them on the graph
2 次查看(过去 30 天)
显示 更早的评论
I could manually go through and find these positive and negative peaks but I want to write a loop that will plot them.
Below is a picture of the data with the peaks that I want labeled.
Not sure how to go about this, maybe list constraints for minimums and maximum values to eliminate other peaks and use the findpeaks function.
*Edit attempt at writing the loop but it is having problems with the bolded sections.
load('x&avdata.mat');
plot(lefttoeavy);
for x=0:2042
if y>3 && y<4.5
findpeaks(lefttoeavy)
elseif y>-3 && y<-4.5
findpeaks(-1*(lefttoeavy))
end
end
3 个评论
Star Strider
2019-11-7
The findpeaks function is easier to work with when its outputs are returned to the calling function workspace.
回答(1 个)
Star Strider
2019-11-7
The findpeaks function has several name-value pair arguments that can help you do what you want, including defining them by prominence. To find the ‘negative peaks’, multiply your signal by -1 to use findpeaks to determine them.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!