islocalmax dont find the first maximum

9 vues (au cours des 30 derniers jours)
Silvio Risse
Silvio Risse le 24 Jan 2019
Commenté : Silvio Risse le 24 Jan 2019
Hello,
if i use islocalmax for a signal like A=[12;12;4;65;43;34;6;7;7;3;768;324;564;23] Matlab throws
ans =
14×1 logical array
0 0 0 1 0 0 0 1 0 0 1 0 1 0
Why Matlab cant find one of the first maximum [12]?
Thank you for help.

Réponse acceptée

Guillaume
Guillaume le 24 Jan 2019
Why Matlab cant find one of the first maximum
Because matlab wants it to be truly a local maxima, that is it needs to be preceded (or followed at the right edge) by lower values. If it's critical that matlab identifies the first (or last) element as a local maxima if the initial (final) slope is downward (resp. upward) then surround your array by -Inf:
A=[12;12;4;65;43;34;6;7;7;3;768;324;564;23];
ismax = islocalmax([-Inf; A; -Inf]);
ismax = ismax(2:end); %to remove the -Inf from the result
  1 commentaire
Silvio Risse
Silvio Risse le 24 Jan 2019
Thank you for your help!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with DSP System Toolbox dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by