I believe that you would probably save time by solving numerically with fzero rather than using symbolic math. For example, the second time I ran this code, I got the following timing information:
tic
fun = @(t)-2.5*t;
intfun = @(x)integral(fun,0,x) + 5;
xval = fzero(intfun,[0,10])
toc
xval =
2
Elapsed time is 0.017252 seconds.
You could probably make it even faster by setting appropriate options, such as a larger-than-default TolX tolerance for fzero.
Alan Weiss
MATLAB mathematical toolbox documentation
Best Answer