matlab.metadata.UnrestrictedDimension - Unrestricted dimension in property size specification - MATLAB (original) (raw)
Main Content
Namespace: matlab.metadata
Superclasses: matlab.metadata.ArrayDimension
Unrestricted dimension in property size specification
Renamed from meta.UnrestrictedDimension
in R2024a
Description
The matlab.metadata.Validation class Size
property usesmatlab.metadata.UnrestrictedDimension
objects to represent the use of a colon in a property size specification. An instance of this class in theSize
array indicates that the respective dimension in the property definition is a colon. A colon in a size specification indicates that any value is allowed.
Examples
The ValidationExample
class specifies the size of the property value as (2,:)
.
classdef ValidationExample properties Prop (2,:) double {mustBeReal, mustBeGreaterThan(Prop, 10)} = 200; end end
Programmatically determine if the property validation used forProp
has an unrestricted dimension.
mc = ?ValidationExample; mp = findobj(mc.PropertyList,'Name','Prop'); sz = mp.Validation.Size; len = length(sz); for k = 1:len if isa(sz(k),'matlab.metadata.UnrestrictedDimension') disp("Dimension " + k + " is unrestricted.") end end
Dimension 2 is unrestricted.
Version History
Introduced in R2018a
The namespace of UnrestrictedDimension
has been changed frommeta
to matlab.metadata
. The 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.UnrestrictedDimension
instance, the code under the case
statement for'meta.UnrestrictedDimension'
does not execute becauseclass(mObj)
returns'matlab.metadata.UnrestrictedDimension'
.
switch class(mObj) case 'meta.UnrestrictedDimension' % code to execute if mObj is a % meta.UnrestrictedDimension 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.UnrestrictedDimension') % code to execute if mObj is a % matlab.metadata.UnrestrictedDimension instance else ... end
If compatibility with older releases of MATLAB is not a concern, you can update'meta.UnrestrictedDimension'
to'matlab.metadata.UnrestrictedDimension'
. However, continue to use the old name if your code needs to run on versions of MATLAB before R2024a.