필터 지우기
필터 지우기

how to extract a column from table ?

조회 수: 1 (최근 30일)
Paolo Ottonelli
Paolo Ottonelli 2020년 1월 14일
답변: David Hill 2020년 1월 14일
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