Computational cost of the commanda 'path'

1 vue (au cours des 30 derniers jours)
Giovanni Gardan
Giovanni Gardan le 20 Sep 2022
Réponse apportée : Rik le 20 Sep 2022
I have a main matlab code, in which there are some scripts. In each of these scripts there are 'path' commands that direct matlab to take some scripts in other directories. My matlab version is 2021b.
I noted (by using "run code and profile command") that almost 90% of the total execution time is due to the 'path' command.
Is there any way to reduce this time? or it is necessary to delete 'path' command and merge all files in one directory needs?

Réponse acceptée

Rik
Rik le 20 Sep 2022
Once you are at the stage where the profiler makes any sense at all, you should question why you are still using scripts instead of functions.
Having code in different folders is not a problem, as you can simply add all required folders to the path. I always do that in a block of code where I set a persistent variable, so the addpath function is called only once for each function.

Plus de réponses (0)

Catégories

En savoir plus sur Search Path 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!

Translated by