필터 지우기
필터 지우기

Grouping data in a table and extracting that section of the table

조회 수: 21 (최근 30일)
John Burford
John Burford 2017년 7월 5일
답변: Manish Annappa 2017년 7월 12일
I have a table of data (mixed strings and numbers). I want to extract rows of the table for each unique group of column 1 and 2. I'm having a problem splitting the table by the array "group".
a = table2array(temp(:,1:1));
b = table2array(temp(:,2:2));
ab = strcat(a,'_',b);
group = findgroups(ab);

답변 (1개)

Manish Annappa
Manish Annappa 2017년 7월 12일
Following document illustrates how to find groups using table variables
Below code illustrates finding groups based on values from first two columns of the table.
>> T = table([1;2;3;1;2],[1;2;4;1;2],[7;8;9;10;11],'VariableNames',{'One' 'Two' 'Three'});
>> [groups,TID] = findgroups(T(:,1:2))
groups =
1
2
3
1
2
TID =
One Two
___ ___
1 1
2 2
3 4

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by