Is there any workaround for the slow performance of path.m?

6 ビュー (過去 30 日間)
Richard Crozier
Richard Crozier 2012 年 10 月 4 日
I use Matlab on multiple machines and generally do not have write access to the directory where the path is saved (i.e. I cannot use the set path dialog or savepath.m to store my path for future sessions). Furthermore, even if I could do this, I want to automatically accomodate changes to the subfolders in my code directories at every startup.
For this reason I generate my path at every startup using a startup script. This script takes several minutes to run with virtually all the time being spent in path.m in the call to the built-in matlabpath function. In a recent startup test, 116.927 seconds were spent on 497 calls to matlabpath.
Is there any way of speeding this up?

採用された回答

Robert Cumming
Robert Cumming 2012 年 10 月 4 日
can you show your code? Are you adding network paths?
I use addpath in the startup.m with no problems (runs very quickly, a few seconds)/
If your sub padirectorys are dynamic then use:
addpath ( genpath ( pwd ) )
  4 件のコメント
Richard Crozier
Richard Crozier 2012 年 10 月 4 日
Posting this has made me realise I should perhaps be building a string similar to the output of genpath in the loop instead of calling addpath, and just calling it once at the end, maybe this will solve the problem.
Richard Crozier
Richard Crozier 2012 年 10 月 4 日
building the string and then calling addpath worked. I'll mark your answer as correct since the comments contain the solution and you made the effort to answer, thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by