matlab.mixin.Heterogeneous.getDefaultScalarElement - Return default object for heterogeneous array operations - MATLAB (original) (raw)

Main Content

Class: matlab.mixin.Heterogeneous
Namespace: matlab.mixin

Return default object for heterogeneous array operations

Syntax

defaultObject = getDefaultScalarElement

Description

[defaultObject](#mw%5F8a1a738e-5071-4ea7-a405-dbe7da8ad5c1) = getDefaultScalarElement returns the default object for a heterogeneous hierarchy. The implementation ofgetDefaultScalarElement inherited from thematlab.mixin.Heterogeneous class returns an instance of the_root class_. The root class is the direct subclass ofmatlab.mixin.Heterogeneous in a heterogeneous hierarchy.

If the root class is abstract or is not an appropriate default object for the classes in the heterogeneous hierarchy, you must override getDefaultScalarElement in the root class to return a default object. getDefaultScalarElement must return a scalar instance of another member of the heterogeneous hierarchy.

MATLABĀ® calls the getDefaultScalarElement method to fill in gaps in a heterogeneous array. For more information, see Defining the Default Object.

Output Arguments

expand all

The default object for a heterogeneous hierarchy.

Attributes

Static true
Access protected

To learn about attributes of methods, seeMethod Attributes.

Examples

This example describes a heterogeneous hierarchy with a root class (FinancialObjects) that is an abstract class and therefore cannot be used for the default object.

Heterogeneous array hierarchy

The FinancialObjects class definition includes an override of thegetDefaultScalarElement method, which returns an instance of theAssets class 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

Tips

Version History

Introduced in R2011b