MATLAB Answers

Knowing the presence of a peak around a point

2 views (last 30 days)
How to know wheather a peak is present around a ponint 'x0' in a 1d plot.
Clearly saying I want to know wheather a peak is present in the space 'x0-d' to 'x0+d' where d is a variable representing the distance from the point x0
  2 Comments
Vinay Killamsetty
Vinay Killamsetty on 30 May 2021
Hi, Walter.
I want to chek whether the Maximum peak of the plot is in the defined range.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 30 May 2021
Assuming you have a vector of x values (rather than x0 being an index), and that your signal is called y:
acceptable_idx = find(abs(x-x0)<=d);
[~, peakidx] = max(y);
if ismember(peakidx, acceptable_idx)
%yes, peak is inside the desired interval
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by