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
KL
2017년 10월 6일
data = xlsread('yourfile.xls');
maxVal = max(data);
[mmaxVal col_no] = max(maxVal)
댓글 수: 2
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!