matlab.metadata.Namespace - Describe MATLAB namespace - MATLAB (original) (raw)

Main Content

Namespace: matlab.metadata
Superclasses: matlab.metadata.MetaData

Describe MATLAB namespace

Renamed from meta.package in R2024a

Description

The matlab.metadata.Namespace class contains information about MATLABĀ® namespaces. All properties are read-only.

Namespaces can contain classes, functions, and contained namespaces (referred to as_inner namespaces_). A namespace can also itself be contained by an_outer namespace_.

The matlab.metadata.Namespace class is a handle class.

Class Attributes

Sealed true
Abstract true
RestrictsSubclassing true
HandleCompatible true

For information on class attributes, see Class Attributes.

Creation

To obtain a matlab.metadata.Namespace object, use thefromName static method. If no such namespace exists,fromName returns an empty object array. For classes in namespaces, thematlab.metadata.Namespace object can also be obtained from theNamespace property of matlab.metadata.Class.

Properties

expand all

Namespace, returned as a character vector.

Short description of the namespace, returned as a character vector.

This property is not used.

List of classes that are scoped to this namespace, returned as an array ofmatlab.metadata.Class objects.

List of functions that are scoped to this namespace, returned as an array ofmatlab.metadata.Method objects.

List of inner namespaces that are contained by this namespace, returned as an array of matlab.metadata.Namespace objects.

Outer namespace that contains this namespace, returned as amatlab.metadata.Namespace object. If this namespace is not contained in another namespace, the matlab.metadata.Namespace object is empty.

Methods

Examples

collapse all

Use the matlab.metadata.Namespace.fromName method to find the names of the classes contained in the matlab.mixin namespace. Access the matlab.metadata.Class objects in theClassList property to display a list of the class names.

disp(string({matlab.metadata.Namespace.fromName("matlab.mixin").ClassList.Name})')

"matlab.mixin.Heterogeneous"
"matlab.mixin.Copyable"
"matlab.mixin.SetGet"
"matlab.mixin.SetGetExactNames"
"matlab.mixin.CustomDisplay"
...

Version History

Introduced in R2008a

expand all

As of R2024a, the namespace, class name, methods, and some properties ofmeta.package have been renamed. Their behavior remains the same.

MATLAB will continue to recognize the old metaclass names in most contexts. However, code that relies on string comparisons to identify metaclasses might need to be updated to continue to work as expected. For example, if mObj in the example below is a matlab.metadata.Namespace instance, the code under thecase statement for 'meta.package' does not execute because class(mObj) returns'matlab.metadata.Namespace'.

switch class(mObj) case 'meta.package' % code to execute if mObj is a meta.package instance ... end

To ensure this code continues to work as intended, use an if statement with isa. The isa command recognizes both the old and new names of the class.

if isa(mObj,'meta.package') % code to execute if mObj is a matlab.metadata.Namespace instance else ... end

If compatibility with older releases of MATLAB is not a concern, you can update 'meta.package' to'matlab.metadata.Namespace'. However, continue to use the old name if your code needs to run on versions of MATLAB before R2024a.