How to find max values in vector for each 10 rows

4 views (last 30 days)
A=rand(1, 100)
For each 10 rows, i want to find max value

Accepted Answer

Jan
Jan on 29 Dec 2022
Edited: Jan on 29 Dec 2022
With the bold guess, that you mean rand(100, 1) instead of rand(1:100):
data = rand(100, 1);
result = max(reshape(data, 10, 10))
% or explicitly:
result = max(reshape(data, 10, 10), [], 1)
  3 Comments
Walter Roberson
Walter Roberson on 29 Dec 2022
are you looking for maximum value minus 1? If so subtract 1 from result
Or are you looking for the indices where the maximums appear? Or for the indices where the second highest appear?
Jan
Jan on 29 Dec 2022
@abdullah al-dulaimi: "the result will be 9 19 29 39 49 59 69 79 89 99"?
Do you mean:
x = 9:10:100

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!