How to find value which is berofe max value of an array?

2 次查看(过去 30 天)
I have an array, let it be r1 = rand(1,100).
I need to find max value and a value which is before maximum. How can i do it?
Maimum = max (r1);
p.s Simple example a = [1, 4, 10, 2, 7, 3, 6];
I know that max is 10, and 7 is before my max value. How to find 7, using Matlab?

采纳的回答

Bryan
Bryan 2019-11-22
编辑:Bryan 2019-11-22
another option would be
max(a(a<max(a)))
  4 个评论
Bryan
Bryan 2019-11-23
编辑:Bryan 2019-11-23
Yes, I agree. Use Walter Roberson's solution.

请先登录,再进行评论。

更多回答(1 个)

Walter Roberson
Walter Roberson 2019-11-22

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by