Maximum arrays of a matrix

Hi i have a matrix woth 543 arrays. I wanna choose 10 maximum arrays between these 543 arrays. Need help!

4 Comments

What exactly is this "matrix of 543 arrays"?
Is it a cell array of arrays?
Are the internal arrays all numeric?
Are they all the same size and class?
What is the maximum array?
Is it the array with the largest sum? The largest mean?
Is it the elementwise maximum of all the arrays?
E.g W=[3 5 4 6 7 8 66 444 33 23 4] 5 top max? Answer: [444 66 33 23 8]
armin m
armin m on 6 Dec 2021
Edited: armin m on 6 Dec 2021
Yes all the same size and numeric. Matrix may changes in each loop
That's just a numeric vector. You said you have a matrix of arrays.

Sign in to comment.

 Accepted Answer

If all you need to work on is a numeric vector, then
W = [3 5 4 6 7 8 66 444 33 23 4];
Wmx = maxk(W,5) % R2017b or newer
Wmx = 1×5
444 66 33 23 8
Note that maxk() is relatively new. You can also do the same thing using sort()
% any version
Wmx = sort(W,'descend');
Wmx = Wmx(1:5)
Wmx = 1×5
444 66 33 23 8

9 Comments

Is it possible to show which row Nd column are that? Without using find function.
maxk can have a second output that is the position
armin m
armin m on 6 Dec 2021
Edited: armin m on 6 Dec 2021
I need it for older version
sort can have a second output that is position

Would you show with above example plz.

[maxvals, idx] = sort(A, 'descend')
maxvals(1:6)
idx(1:6)
armin m
armin m on 6 Dec 2021
Edited: armin m on 6 Dec 2021
I need something thatvworks with matrix with more than one col or row. It does not give 6 max. It fist sort each col from high to low and then shows which numbers in each col have max vals. Maxvals(1:6) and idx(1:6) just shows 1 to 6 numbers and their position, not top 6 numbers and their position!! Tnx.
That do my work. But if that can be use for more than 1 ro and column, it is better.thank a lot
use ind2sub() to convert the second output into a row and column number.

Sign in to comment.

More Answers (0)

Categories

Asked:

on 5 Dec 2021

Commented:

on 6 Dec 2021

Community Treasure Hunt

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

Start Hunting!