Borrar filtros
Borrar filtros

How to operate on One Column of A matrix while the other Columns stay connected row-wise to the column we are operating on

4 visualizaciones (últimos 30 días)
Hi, sorry for bad wording but suppose i have this matrix
A =
1 2
1 3
2 5
2 4
4 2
6 1
8 1
I want to find the maximum of the first column while still connect the second value to the output for example if i ask the output of max 1st column of A itu will return the value of :
8 1
moreover, I want to rank the matrix from the largest value, based on column 1 while still connect the first column to the second, the desired output is this:
8 1
6 1
4 2
2 5
2 4
1 3
1 2
how can i do that?
lastly i want to find the average of the third largest value of the above matrix, based on the value of the first column, column wise. The desired output is this:
6 1.333
again, I'm sorry for bad wording, Any help will be greatly appreciated.

Respuesta aceptada

Maxi
Maxi el 17 de Mayo de 2021
first problem could be solved with
index_max=find(max(A(:,1))==A(:,1)) %find the index of the largest value in the first column
A(index_max,:)
>>ans =
8 1

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by