フィルターのクリア

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 ビュー (過去 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?

回答 (2 件)

Cam Salzberger
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
  1 件のコメント
Debbie Oomen
Debbie Oomen 2017 年 10 月 7 日
Thank you. Now how can I display all the values of that column? I can now only see the column number

サインインしてコメントする。


KL
KL 2017 年 10 月 6 日
data = xlsread('yourfile.xls');
maxVal = max(data);
[mmaxVal col_no] = max(maxVal)
  2 件のコメント
Debbie Oomen
Debbie Oomen 2017 年 10 月 7 日
Thank you. I can see the column number but how can I display the entire column with all its values?
KL
KL 2017 年 10 月 8 日
data(:,col_no)
should display that column.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by