en fr

Disponible uniquement en anglais

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Class and Object Functions

class

Object creation.

Syntax

object = class(strct, 'classname')
object = class(strct, 'classname', parent1, ...)
str = class(object)

Description

class(strct,'classname') makes an object of the specified class with the data of structure strct. Object fields can be accessed only from methods of that class, i.e. functions whose name is classname::methodname. Objects must be created by the class constructor classname::classname.

class(strct,'classname',parent1,...) makes an object of the specified class which inherits fields and methods from one or several other object(s) parent1, ... Parent objects are inserted as additional fields in the object, with the same name as the class. Fields of parent objects cannot be directly accessed by the new object's methods, only by the parent's methods.

class(object) gives the class of object as a string. The table below gives the name of native types.

ClassNative type
doublereal or complex double scalar or array
singlereal or complex single scalar or array
int8/16/32/648/16/32/64-bit signed integer scalar or array
uint8/16/32/648/16/32/64-bit unsigned integer scalar or array
logicallogical scalar or array
charcharacter or character array
listlist
cellcell array
structscalar structure
structarraystructure array
inlineinline function
funreffunction reference
nullnull value

Examples

o1 = class({fld1=1, fld2=rand(4)}, 'c1');
o2 = class({fld3='abc'}, 'c2', o1);
class(o2)
  c2

See also

struct, inferiorto, superiorto, isa, isobject, methods

inferiorto

Set class precedence.

Syntax

inferiorto('class1', ...)

Description

Called in a constructor, inferiorto('class1',...) specifies that the class has a lower precedence than classes whose names are given as input arguments. Precedence is used when a function has object arguments of different classes: the method defined for the class with the highest precedence is called.

See also

superiorto, class

isa

Test for an object of a given class.

Syntax

b = isa(object,'classname')

Description

isa(object,'classname') returns true of object is an object of class class, directly or by inheritance. In addition to the class names given by class, the following classes are supported:

ClassNative type
celllist or cell array
numericdouble, single or integer scalar or array
floatdouble or single scalar or array
integerinteger scalar or array

Example

isa(pi,'double')
  true

See also

class, isobject, methods

isnull

Test for a null value.

Syntax

b = isnull(a)

Description

isnull(a) returns true if a is the null value created with null, or false for any value of any other type.

See also

class, null

isobject

Test for an object.

Syntax

b = isobject(a)

Description

object(a) returns true if a is an object created with class.

See also

class, isa, isstruct

methods

List of methods for a class.

Syntax

methods classname
list = methods('classname')

Description

methods classname displays the list of methods defined for class classname. Inherited methods and private methods are ignored. With an output argument, methods gives produces a list of strings.

See also

class, info

null

Null value.

Syntax

obj = null

Description

null gives the only value of the null data type. It stands for the lack of any value. Null values can be tested with isnull or with equality or inequality operators == and ~=.

With an input argument, null(A) gives the null space of matrix A.

Examples

n = null
  n =
    null
isnull(n)
  true
n == null
  true
n ~= null
  false
class(n)
  null

See also

isnull, null (linear algebra)

superclasses

Get list of superclasses.

Syntax

list = superclasses(obj)

Description

superclasses(obj) gives the list of the names of parent classes (superclasses) of the object obj. Parent classes are specified as additional arguments to class when the object is constructed.

Example

use lti;
G = tf(1, [1, 2]);
class(G)
  tf
superclasses(G)
  {'lti'}
isa(G, 'lti')
  true

See also

class, isa