I was testing with the symbolic toolbox of Matlab. And wonder why it is so slow even when just calculating with symbolic numbers. To test it I wrote this
syms x
x = subs(x,1);
a = 1;
tic
for i=1:10000
z_sym = x + 1;
end
toc
tic
for i=1:10000
z_num = a + 1;
end
toc
For the first loop it says Elapsed time is 4.358483 seconds.
and for the second on Elapsed time is 0.000029 seconds.
. I know using the subs function gives me x=1 but it’s still of the typ sym
and I could convert it with a cast to speed things up. But that’s the point.
Why it takes around 15000 times longer to calculate 1+1 symbolic than it takes numeric. What is slowing Matlab so hard?