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?
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(2 个)
Cam Salzberger
2017-10-6
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!