copy the data stored in the object properties. The copy refers to the same object as the
original handle. If you change a property value on the original object, the copied handle
references the same change.
Handle Object Behavior
Here is a handle class that stores a value in its Number property. The default property
value is the number 1.
classdef NumHandle < handle
properties
Number = 1
end
end
Create a NumHandle objects assigned to the variable a.
a = NumHandle
a =
NumHandle with properties:
Number: 1
Assign the value of a to another variable, b.
b = a
b =
NumHandle with properties:
Number: 1
The variables a and b refer to the same underlying object. Changing the value of the
Number property of a also changes the Number property of b. That is, a and b refer to the
same object.
a.Number = 7
a =
NumHandle with properties:
7 Value or Handle Class — Which to Use