How to generate all paths or directories that are actually used by a script?

2 ビュー (過去 30 日間)
jiansong wan
jiansong wan 2020 年 11 月 9 日
コメント済み: jiansong wan 2020 年 11 月 16 日
Sometimes the paths contains more than necessary directories for my script.
It is very tedious to get exact which function/script is from which path.
Now I want to run a script, and let Matlab record all the directories it ever visisted/referred in its path, and show it to me so I can simplify the path setting.
Will this be something alreay existed in Matlab?
Thanks!

回答 (1 件)

Pranav Verma
Pranav Verma 2020 年 11 月 13 日
Hi Jiansong,
Please refer to dbstack functionality. You can see the location of the functions by setting breakpoints at those functions. Use the "-completenames" option to get the full path of the functions. Below is the snippet from the documentation:
It should help in getting the path to which a function belongs.
Thanks
  1 件のコメント
jiansong wan
jiansong wan 2020 年 11 月 16 日
Hi Pranav,
This dbstack doesn't seem to help.
as an example, I have a script(A), not even a function, it calls a few other scripts and functions(B) while excuting. How do I know which path was used during excuting script(A)?
In the 'set path' UI, I added a lot of folders, inherenting from colleagues's setups. And I'm sure there are a lot of path overlapping each other. My goal is simplifing/reducing the paths to its minimum. If Matlab can keep a actual path record when excuting script(A), then I can just use that record in 'set path'.
Would this be possible?
Thanks!

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

カテゴリ

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

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by