how to extract a column from table ?

3 次查看(过去 30 天)
Hi, I have a table and i would like to create a function that extract a column in which the sum of the elemnts is the highest ; in the following case, for example i have
a b c d
________ ________ ________ ________
3.04 0.2 0.12 0.81
2.24 0.1 0.08 0.47
2.24 0.1 0.08 0.47
2.24 0.1 0.08 0.47
2.24 0.1 0.08 0.47
2.78 0.1 0.08 0.47
2.78 0.1 0.08 0.57
2.78 0.1 0.08 0.57
2.78 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
3.2 0.1 0.08 0.57
function M=Max(Y)
A = varfun(@sum,Y);
[~,I] = varfun(@max,A)
M=Y(:,I);
But I don't know how to extract maximum and his position

采纳的回答

David Hill
David Hill 2020-1-14
Not sure why you need a table, but convert to matrix, then:
[~,idx]=max(sum(y));%idx will give you the column number of the max sum.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by