MATLAB Object-Oriented Programming

(Joyce) #1
Size Class Implicit Default Assigned
by MATLAB
(m,n) Any numeric m-by-n array of zeros of
specified class.
(m,:) or (:,n) Any class m-by-0 or 0-by-n of specified
class.
(m,n) char m-by-n char array of spaces.
(m,n) cell m-by-n cell array with each
cell containing an 0-by-0
double.
(m,n) struct m-by-n struct
(m,n) string m-by-n string
(m,n) enumeration class First enumeration member
defined in the class.
(1,1) function_handle Runtime error — define a
default value in the class.

To determine the implicit default value for nonzero and explicit size specifications,
MATLAB calls the default class constructor and builds an array of the specified size using
the instance returned by the constructor call. If the class does not support a default
constructor (that is, a constructor called with no arguments), then MATLAB throws an
error when instantiating the class containing the validation.

If the specified size has any zero or unrestricted (:) dimensions, MATLAB creates a
default value that is an empty array with the unrestricted dimension set to zero.

For heterogeneous arrays, MATLAB calls the getDefaultScalarElement method to get
the default object.

See Also


Related Examples



  • “Validate Property Values” on page 8-24

  • “Property Validation Functions” on page 8-40


8 Properties — Storing Class Data

Free download pdf