How to test if a function handle belongs to a particular package?
7 views (last 30 days)
I have a method that accepts a function handle and then needs to branch depending on whether that function is part of +package1 or +package2. While I can think of some hacks involving parsing the function name and/or package's help text and/or output of dir, is there a better or simpler way?
Guillaume on 28 Apr 2017
Probably the simplest would be to parse the output of
The file field of that output will contain the full path to the anonymous function, so will contain the package name, if any.
More Answers (1)
Image Analyst on 29 Apr 2017
As an example, to find out the folder of the bwdist function in the Image Processing Toolbox:
functionInfo = which('bwdist')
[folder, baseFileNameNoExt, ext] = fileparts(functionInfo)
Here is the file/folder info that is returned:
Adapt as needed for your function names.