Minimum and Maximum after maximum value

1 Ansicht (letzte 30 Tage)
jason
jason am 11 Sep. 2022
Bearbeitet: Torsten am 11 Sep. 2022
I need to find the minimum value after the max has occurred. For example, in [1 5 7 3 2 6], the max is 7, and I would want to find 2.

Akzeptierte Antwort

Torsten
Torsten am 11 Sep. 2022
Bearbeitet: Torsten am 11 Sep. 2022
The first element of v which is a maximum is taken.
If the last element of v is the maximum, m will be empty.
v = [1 5 7 3 2 6];
[~,idx] = max(v);
m = min(v(idx(1)+1:end))

Weitere Antworten (0)

Kategorien

Mehr zu Operating on Diagonal Matrices finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by