I have three columns in an excel file and i want MATLAB to find the maximum value from all columns and return the column where the maximum is found. How to do this?

2 vues (au cours des 30 derniers jours)
I have three columns in an excel file and i want MATLAB to find the maximum value from all columns and return the column where the maximum is found. How to do this?

Réponses (2)

Cam Salzberger
Cam Salzberger le 6 Oct 2017
Hello Debbie,
There are a couple of ways you could do this. One is to use max to find the maximum of each column, and then max on that to find which column:
maxOfCols = max(A);
[~, colIdxOfMax] = max(maxOfCols);
Another would be to just find the linear index of the maximum, then translate out the column index from that:
[~, linIdxOfMax] = max(A(:));
[~, colIdxOfMax] = ind2sub(size(A), linIdxOfMax);
-Cam

KL
KL le 6 Oct 2017
data = xlsread('yourfile.xls');
maxVal = max(data);
[mmaxVal col_no] = max(maxVal)
  2 commentaires
Debbie Oomen
Debbie Oomen le 7 Oct 2017
Thank you. I can see the column number but how can I display the entire column with all its values?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by