David Kelley
David Kelley

Reputation: 1448

Faster Matlab Table Creation

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?

Upvotes: 3

Views: 542

Answers (1)

David Kelley
David Kelley

Reputation: 1448

Based on this reply from a MathWorks employee, you can't do it without altering the core Matlab files.

Upvotes: 1

Related Questions