Simplicity
Simplicity

Reputation: 48916

Matlab - handle

In programming in Matlab, if I pass by a statement as follows:

classdef xyz < handle

What does this mean?

Upvotes: 1

Views: 142

Answers (2)

Andrey Rubshtein
Andrey Rubshtein

Reputation: 20915

Please read the manual:

A handle class constructor returns a handle object that is a reference to the object created. You can assign the handle object to multiple variables or pass it to functions without causing MATLAB to make a copy of the original object. A function that modifies a handle object passed as an input argument does not need to return the object.

Upvotes: 1

Phonon
Phonon

Reputation: 12727

This line makes your xyz class inherit from the handle class. The handle class allows your object to be passed into other functions by reference. This means that if you have a functionfoo(x) that modifies x internally, your x will be modified in the caller after the function returns. A good article on this topic can be found here.

Upvotes: 1

Related Questions