list of varialbes used in a m file

2 ビュー (過去 30 日間)
Fan Mei
Fan Mei 2018 年 11 月 30 日
編集済み: Stephen23 2018 年 12 月 1 日
Is there an easy way in Matlab to get the list of variables, which are called or used in a 'm' file? I received a program from a collaborator. That program (1st program) runs with several functions and generates hundreds of variables, then another program (2nd program) will use sub potions of the variables in the workspace. I do not want to rerun 1str program every time. However, if I save the whole workplace, it is about several GB per case. Thus, I hope that I can only save the variables which will be used by the 2ndprogram. How do I find a list of those vaialbes used by the 2nd program?
  2 件のコメント
Walter Roberson
Walter Roberson 2018 年 12 月 1 日
Stephen23
Stephen23 2018 年 12 月 1 日
編集済み: Stephen23 2018 年 12 月 1 日
"... and generates hundreds of variables"
And that is the bad design decision right there. Bad design decisions make code slow, complex, buggy, and hard to debug. This bad design decision has already slowed down your code development.

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

採用された回答

Guillaume
Guillaume 2018 年 11 月 30 日
No, matlab does not have a way to get the list of variables in a script. Possibly, you could cobble something together using undocumented functions such as mtree but that would be a lot of work for something that you shouldn't have to do.
In my opinion, you would be better off rewriting the code. It sounds like it is written as one monolithic huge script which is an extremely bad design. The code should use functions to subdivide tasks. Any single script/function that holds 100s of variables at once is a maintenance nightmare.

その他の回答 (1 件)

Fan Mei
Fan Mei 2018 年 11 月 30 日
Thank you for your help, Guillaume

カテゴリ

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

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by