MATLAB: Problem Using groupsummary function

counting tablescounting variablesgroupsummary

Hi, I'm trying to count how many times a coordinate (x,y) repeats in a file. I'm using this code:
SBc='sb-noH_2R401_Coord.gtxt'; % Nombre del archivo a abrir
SBIDc = fopen(SBc); % Abre el archivo
cell = textscan(SBIDc,' % f %f'); %Escanea la información del archivo y la almacena en una 'célula'.
fclose(SBIDc);
mc=cell2mat(cell); % convierte la celula en matriz
table1=table(mc(:,1)); % convierte a tabla la info
table2=table(mc(:,2));
zt=table(table1,table2,'VariableNames',{'xc','yc'});
count=groupsummary(zt,{'xc','yc'})
And, I'm getting this error:
Error using matlab.internal.math.grp2idx (line 172)
A grouping variable of class 'table' is not supported.
Error in matlab.internal.math.mgrp2idx (line 93)
[g,countgrp(j),gd{1,j}] = matlab.internal.math.grp2idx(group{1,j},inclnan,inclempty);
Error in groupsummary (line 385)
[gvidx,numgroups,gdata,gcount] = matlab.internal.math.mgrp2idx(groupingdata,size(T,1),inclnan,inclempty);
Any idea what I'm doing wrong?
I did all this once and I got it right, now I don't understand why it's not working
Thank you

Best Answer

The error message tells you the problem:
A grouping variable of class 'table' is not supported.
This line,
zt=table(table1,table2,'VariableNames',{'xc','yc'});
combines two tables. zt.xc is a table within the zt table. Same with zt.yc.
The grouping variable cannot be a table.
If table1 and table2 are tables with a single column and an equal number of rows, you can combine them horizontally like this.
zt = [table1, table2];
You can change the variable names before or after combing the table columns.
If those tables do not have single columns, you can continue with your current method but you'll need to specify the grouping column differently.