Return the table column # containing the maximum value in a row
13 ビュー (過去 30 日間)
古いコメントを表示
In my table, T, columns 14 through 27 contain numeric data. I want to find the maximum value in each row and then return the associated column # or column title.
I can get the value with:
for i=1:size(T)
maximum = max(T{i,14:27});
end
But I'm struggling to get the associated column # or title.
0 件のコメント
回答 (1 件)
Peter Perkins
2017 年 4 月 25 日
I think you want something like this:
[maxVals,maxLocs] = max(T{:,14:27},[],2)
In other words, for the contents of the 14th-27th variables in T, find the maximum value and the variable in which it occurred. If you want the var names, follow up with this:
maxVarNames = T.Properties.VariableNames(maxLocs)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!