MATLAB: Trying to reduce computation time

computing time

Hey, I am trying to implement a code to compute the values of two functions using a large array of input.
visitst = symfun(exp(T/4)+1000,T);
visitsp = symfun(-10*(P-10)^2+5000,P);
for i=1:n
Values1(i) = visitst(Input1(i));
Values2(i) = visitsp(Input2(i));
end
I am looking to go through an "Input1" and "Input2" array of 100k+ different inputs, but even 1000 are taking extremely long computing times. Can someone suggest a method of improving this?

Best Answer

Pre-allocation the output before the loop:
Value1 = zeros(1, n);
Value2 = zeros(1, n);
I do not expect, that this is the bottleneck. But the costs of a forgotton pre-allocation grow exponentially, such that there is a limit in the input size, where this becomes the bottleneck.