Anonymous function versus File in matlabfunction
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I am creating several large functions from symbolic expressions (jacobians used in optimization).
I've noticed that it takes some time to create the file output using
matlabFunction(jacob,'File','jacobianFunctinName','Vars',{listOfSymbolicVars})
Using an anonymous function, it is MUCH faster:
jacfun=matlabFunction(jacob,'Vars',{listOfSymbolicVars})
Is there a reason for this (profiling the code points out matlabWrite)? I know that anonymous functions were slower in past releases; should I pay the price up front to make the file, or just use the anonymous function?
Thanks,
Brad
0 Kommentare
Antworten (1)
Walter Roberson
am 22 Dez. 2016
"By default, matlabFunction with the File argument generates a file containing optimized code. Code optimization means that intermediate variables are used to simplify or speed up the code. MATLAB generates intermediate variables as a lowercase letter t followed by an automatically generated number, for example t32.
matlabFunction without the File argument (or with a file path specified by an empty character vector) creates a function handle. In this case, the code is not optimized. If you try to enforce code optimization by setting Optimize to true, then matlabFunction throws an error."
0 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!