Hello everybody,
I don't understand why the below (sketched) code is slow.
Consider the following vector, with element potentially repeated and the vector of unique values associated to it:
potential_rep_idx = categorical(randi(N,1));
unique_idx = unique(potential_rep_idx);
The purpose of the code is to take a table called "table_of_stuff" made of a table "table_other stuff", made of several columns of various types (double, datetime, cells, strings) and the above vector as follows:
table_of_stuff = [array2table(potential_rep_idx), table_other_stuff]
and identify, for each element of unique_idx, all lines of table_of_stuff in which the element appears. Then, from all these lines, make one single line in which each element corresponds to the mode of the values for that column.
In other words:
table_of_stuff = a long table with columns of various type (double, datetime, cells, strings)
table_of_stuff = categorical(table_of_stuff);
find_idx = find( potential_rep_idx == unique_idx(i) ) ;
mode_table(i,:) = array2table(mode((table_of_stuff{find_idx, : }),1));