how to extract a column from table ?

1 visualizzazione (ultimi 30 giorni)
Paolo Ottonelli
Paolo Ottonelli il 14 Gen 2020
Risposto: David Hill il 14 Gen 2020
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

Risposta accettata

David Hill
David Hill il 14 Gen 2020
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.

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by