Filter löschen
Filter löschen

Computational cost of the commanda 'path'

4 Ansichten (letzte 30 Tage)
Giovanni Gardan
Giovanni Gardan am 20 Sep. 2022
Beantwortet: Rik am 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?

Akzeptierte Antwort

Rik
Rik am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Search Path finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by