Anonymous function versus File in matlabfunction
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Walter Roberson
il 22 Dic 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 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!