Is there exist() functionality for packages/namespaces?

5 views (last 30 days)
Create a package and put it somewhere in Matlab's path. If you know the parent directory, you could use exist('/path/+package'), but you don't need to know the path to use the package, so that's silly.
The current best solution I have is to try/catch calling a function in the package.

Accepted Answer

Walter Roberson
Walter Roberson on 6 Jan 2023
You can exist() a function inside the package
exist('matlab.internal.lang.capability.Capability')
ans = 8
which matlab.internal.lang.capability.Capability
/MATLAB/toolbox/matlab/capabilities/+matlab/+internal/+lang/+capability/Capability.m % matlab.internal.lang.capability.Capability constructor
You can also which the + form of a function (but not the package itself)
which +matlab/+internal/+lang/+capability/Capability
/MATLAB/toolbox/matlab/capabilities/+matlab/+internal/+lang/+capability/Capability.m % matlab.internal.lang.capability.Capability constructor
which +matlab/+internal/+lang/+capability
'+matlab/+internal/+lang/+capability' not found.
  5 Comments
Walter Roberson
Walter Roberson on 7 Jan 2023
Class methods can be found using which, but sometimes they will not be located unless the class has been loaded at least once in this session (since the last clear classes)

Sign in to comment.

More Answers (0)

Categories

Find more on Performance and Memory in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by