MATLAB: How to extract a column from table

MATLAB and Simulink Student Suitemaxsumtablevariable

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

Best Answer

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.