Skip to Main Content Skip to Search
Product Documentation

matlab.mixin.Heterogeneous.getDefaultScalarElement - Class: matlab.mixin.Heterogeneous
Package: matlab.mixin

Return default object for heterogeneous array operations

Syntax

defaultObject = getDefaultScalarElement

Description

defaultObject = getDefaultScalarElement returns the default object for a heterogeneous hierarchy. Override this method if the Root Class is abstract or is not an appropriate default object for the classes in the heterogeneous hierarchy. getDefaultScalarElement must return an instance of another member of the heterogeneous hierarchy.

The matlab.mixin.Heterogeneous class provided a default implementation of this method that returns an instance of the Root Class.

MATLAB calls the getDefaultScalarElement method when requiring a default object. See matlab.mixin.Heterogeneous for more information on heterogeneous arrays and default objects.

Tips

Output Arguments

defaultObject

The default object for heterogeneous array operations.

Definitions

Root Class

Root class – The direct subclass of matlab.mixin.Heterogeneous that forms the root of a heterogeneous hierarchy. Classes of objects that you can combine into heterogeneous arrays must derive from this root class.

Attributes

Statictrue
AccessProtected
Sealedtrue not required

To learn about attributes of methods, see Method Attributes in the MATLAB Object-Oriented Programming documentation.

Examples

This example describes a heterogeneous hierarchy with a root class (FinancialObjects) that is an abstract class and cannot, therefore, be used for the default object. The FinancialObjects class definition includes an override of the getDefaultScalarElement method which returns an instance of the Assets class as the default object.

The root class can override the getDefaultScalarElement method that is defined in matlab.mixin.Heterogeneous class and return an Assets object as the default object.

classdef FinancialObjects < matlab.mixin.Heterogeneous
   methods (Abstract)
      val = determineCurrentValue(obj)
   end
   methods (Static, Sealed, Access = protected)
      function default_object = getDefaultScalarElement
         default_object = Assets;
      end
   end
end

See Also

matlab.mixin.Heterogeneous

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS