- no entry needs to be made in the symbol table (but the entry would just be a name pointing to data that was being carried around anyhow)
- There are checks for timer interruption every line, and the first form has two lines, so the second form has one fewer check for interruptions
What is the most efficient way of calling two related functions in Matlab?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ak K
le 28 Juil 2018
Commenté : Walter Roberson
le 28 Juil 2018
Hi, I am wondering if one of the two following options are more efficient/better to use while coding
This:
a = functionA(5);
b = functionB(a);
Or This:
B = functionB(functionA(5));
Which way would be more efficient to find the same value, B?
0 commentaires
Réponse acceptée
Walter Roberson
le 28 Juil 2018
The second is faster by a small amount:
2 commentaires
Walter Roberson
le 28 Juil 2018
But it's always a good idea to time.
If you run this and look at the graphs, you can see that the first runs are sometimes slower for an indefinite period (blue is higher but eventually drops) and that the second round of running an identical call can sometimes be faster. But you will also see that the long term average appears to favor separate statements -- the opposite of what I said. I cannot account for this.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!