movmax - remove duplicated

조회 수: 13 (최근 30일)
Jenny Besedin
Jenny Besedin 2019년 7월 29일
편집: Adam Danz 2019년 7월 30일
Hello,
I am using movmax in order to find local maximum values on a very long vector.
i want to create a vector which will not include the repetitive number of the maximum value.
it means that if my vector is: y= [2,3,4,5,4,3,2]
and I use: movmax(y,3)
the result will be: 3 4 5 5 5 4 3
what I wish to get is that if there is repetitive maximum value it will show it only once:
the result will be: 3 4 5 4 3
how can I do that?

답변 (2개)

Adam Danz
Adam Danz 2019년 7월 29일
편집: Adam Danz 2019년 7월 30일
y= [2,3,4,5,4,3,2];
m = movmax(y,3);
m([1,diff(m)]==0) = [];

Andrei Bobrov
Andrei Bobrov 2019년 7월 30일
y = [2,3,4,5,4,3,2];
v = movmax(y,3);
out = v(diff([0,v])~=0);

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by