I've noticed that creating fairly large tables in Matlab (>10,000 rows) can be quite slow because of a single function called by the constructor, checkDuplicateNames. However, I commonly am sure that the names I'm passing the table are already unique.
The following illustrates the problem well. Generating 10,000 random values takes less than a millisecond but generating a table of random values with string row names takes a second and a half with 1.4 second taken by checking for duplicate row names:
profile on;
a = rand(10000,1);
strind = cellstr(num2str((1:10000)'));
b = table(a, 'RowNames', strind);
profile viewer
I'm curious then, is there an alternate way to create tables in Matlab without calling the checkDuplicateNames function?
table.mfunction is editable, why not copy its contents and create atablewithoutchecks.mfile by removing the slow lines? - Wouter KuijsterssetRowNamesis called. There is aallowDupsargument, that when set to1, bypasses the check that takes up so much time. Sadly, I couldn't find how you can setallowDups = 1at the time you call thetablefunction, so you may still have to create some duplicate functions to get it to work. - Wouter Kuijsters@tablein the base Matlab installation) that I would have to copy, I'm doubtful that this approach would give me atableobject at the end instead of a new type that doesn't work with functions written for tables. - David KelleycheckDuplicateNamesfunction with a version of your own that does nothing? - Luis Mendo