Function for more scripts slower?
Show older comments
Hi, I have a function that is used in different scripts. I would know if is more time saving changing the name of the function and use for each script different functions.
I'm worried about the fact that if one function is opened in a script, the other script have to wait that the function is closed to open again the same function and in this way the computational time gets longer.
Thanks.
2 Comments
" I would know if is more time saving changing the name of the function and use for each script different functions."
No. That would just make managing your code more difficult and slow your code down.
"I'm worried about the fact that if one function is opened in a script, the other script have to wait that the function is closed to open again the same function and in this way the computational time gets longer."
MATLAB functions are not "opened" or "closed" when they are run (and certainly not individually each time they are called). MATLAB code is compiled and stored in memory: it makes no difference after that how many times it is called or from where. Your proposal (of making multiple copies of a function) would slow down your code because every function would need to be compiled separately (thus also pointlessly wasting memory):
So far I do not see any single advantage in what you are proposing.
Antonio Boccamazzo
on 11 Apr 2019
Answers (0)
Categories
Find more on Application Deployment in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!