How to get a list of local functions in a MATLAB file?

31 ビュー (過去 30 日間)
Balaji
Balaji 2014 年 9 月 5 日
編集済み: tommsch 2020 年 11 月 30 日
Hi,
I would like to get a list of all local functions in a .m file. The localfunctions function does not work in the context of command window or other functions.
Is there a simpler way to achieve this apart from parsing through a file to find the local function names?
Thanks, Balaji

回答 (2 件)

Star Strider
Star Strider 2014 年 9 月 5 日
Here’s a list of search results of MATLAB online documentation that provides functions that list dependencies. Maybe one of these will work for you. I can’t be more specific because I don’t know what you’re looking for.
  2 件のコメント
Balaji
Balaji 2014 年 9 月 6 日
Thanks for the reply.
What I am looking for is say you have something like this
In the above link the function mystats has 2 local functions mymean and mymedian.
I have a similar setup on my end.
Now the questions is there a way to call some function on mystats and get mymean,mymedian as output? i.e listing all local functions in a file.
Star Strider
Star Strider 2014 年 9 月 6 日
I searched using all the search terms I could think of, but it doesn’t seem there is such a command-line function. In the interests of time, I’ll simply present Identify Program Dependencies for you to explore.
I didn’t even know the matlab.codetools.requiredFilesAndProducts function existed until I searched for it a few minutes ago, so I have no personal experience with it. (My experiments with the matlab.codetools.requiredFilesAndProducts function with Matt Fig’s combinator.m that has several user-written functions local to it, failed to list them. Perhaps I'm not using all of its functionality correctly, though.)
It would seem that a useful (and straightforward and uncomplicated) way to do this would be preferable.

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


tommsch
tommsch 2020 年 11 月 30 日
編集済み: tommsch 2020 年 11 月 30 日
See my submission allfunctionhandle, it returns handles to the local functions without the need to modify the source code.

カテゴリ

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