フィルターのクリア

Computational cost of the commanda 'path'

4 ビュー (過去 30 日間)
Giovanni Gardan
Giovanni Gardan 2022 年 9 月 20 日
回答済み: Rik 2022 年 9 月 20 日
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?

採用された回答

Rik
Rik 2022 年 9 月 20 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSearch Path についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by