MATLAB: How to break a large table into a set of smaller tables

table

This question is asked before and my problem is that the one of the columns are string not numbers and I recieve this error "Error using ==
Comparison between double and string is not supported." when using this code taken from the answers to the above question:
col24 = T{:,[27 28]};
u24 = unique(col24, 'rows');
numentry = size(u24,1);
TableCell = cell(numentry,1);
for K = 1 : numentry
insubset = T{:,27} == u24(K,1) && T{:,28} == u24(K,2);
TableCell{K} = BigTable(insubset,:);
end
Alos is it possible to use the name of columns instead of numnber so instead of 27 and 28 which are the column number in col24 = T{:,[27 28]}; use the name of those columns?

Best Answer

col24 = T(:,[27 28]); %notice () not {} . Output is table
u24 = unique(col24, 'rows'); %output is table
numentry = size(u24,1);
TableCell = cell(numentry,1);
for K = 1 : numentry
insubset = strcmp(T{:,27},u24{K,1}) & T{:,28} == u24{K,2}; %notice {} not ()
TableCell{K} = T(insubset,:);
end
Note: this code should work even if column 27 is cell array of character vector instead of string data type. If you are sure you will have string() datatype then
insubset = T{:,27} == u24{K,1} & T{:,28} == u24{K,2};
will also work.