Function for more scripts slower?

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 个评论

" 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.
Very clear. Thank you very much.

请先登录,再进行评论。

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Application Deployment 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by