How to speed up function approximation?
Mostrar comentarios más antiguos
I have a code in MATLAB2016:
...
tic
is_t1(:,i)=(is_t1(:,i)/mmax);
[f,r2]=fit(tr,is_t1(:,i),'1-b*exp(-((a*x)/(var_c)))','StartPoint',[0.8 0.8]);
T1(i)=-(var_c*log(-(0.6321 – 1)/f.b))/f.a;
toc
...
end
Its execution time: ~0,031s
Number of approximation points in a given task: ~7000-10000
How to ,speed up this operation?
Thanks for any help
Respuesta aceptada
Más respuestas (2)
Chris
el 19 de Ag. de 2019
0 votos
I dont have those toolboxes but often you can start an optimization problem with a randomly selected sub-set of data run for a short time to get a better initial guess before running the algorithm over all your data. YMMV. Take care with this and make sure you understand your data and how you are modeling it.
1 comentario
Adrian T
el 19 de Ag. de 2019
Yair Altman
el 19 de Ag. de 2019
0 votos
It may be useful to replace the string with a function handle.
Also, setting the convergence tolerances to smaller values than the defaults might converge faster without a meaningful degradation of the result.
Lastly, read https://undocumentedmatlab.com/blog/speeding-up-builtin-matlab-functions-part-1 where I discuss different ways of significantly speeding-up the fitdist function. It's not the same as your fit but similar ideas can possibly also be useful in your case.
1 comentario
Adrian T
el 19 de Ag. de 2019
Categorías
Más información sobre Elementary Math en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!