Computational cost of the commanda 'path'

1 visualización (últimos 30 días)
Giovanni Gardan
Giovanni Gardan el 20 de Sept. de 2022
Respondida: Rik el 20 de Sept. de 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?

Respuesta aceptada

Rik
Rik el 20 de Sept. de 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.

Más respuestas (0)

Categorías

Más información sobre Search Path en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by