Use info in the row based on it being the max value

1 visualización (últimos 30 días)
Sofia
Sofia el 1 de Feb. de 2024
Respondida: Stephen23 el 1 de Feb. de 2024
I have an excel sheet with info that i turned into a matrix, there is info on year, distance, diameter, energy etc.
I did determine the biggest object in diameter using max(), now based on the location of that cell in need to use the info in that ROW without hardcoding. How do I chain index the row based on the max value in the column from previous condition? See code below..
neos = readmatrix('neosData.xlsx');
mat = neos
diameter = mat(:,7);
maxDiameter = max(diameter);

Respuestas (1)

Stephen23
Stephen23 el 1 de Feb. de 2024
The second output from MAX is the index, you can use that:
[maxDiameter,idx] = max(diameter);
row = mat(idx,:)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by