Dear all,
I am struggling to solve a problem concerning handle objects. Let me first explain my object constallations. I have three different classes:
Node class:
classdef Node < handle properties X %double
Y %double Z %double endend
Element class:
classdef Element < handle properties Nodes % Node objects (1x4)
endend
Mesh class:
classdef Element < handle properties Elements % Element objects (1xN)
Nodes % List of all nodes in Element
endend
The is an abstraction of my problem. Now I want to merge two Nodes ( Node1 into Node 2).
The Idea is either :
- To change all Pointer of the handle object Node1 to Pointer to Node2
- Change 'root object' of Node1 (where the pointer references to) to the 'root object' of Node2, so that the pointer redirect all?!
- Delete Node1 and during deletion replace by a pointer to Node2
The problems:
- I didn't find any method to get all Pointer to Node1
- How can I acces this 'root object'
- No idea if and how it is possible
I have tried:
classdef Node < handle properties X %double Y %double Z %double end methods function merge2(obj,NewNode) obj = NewNode; end endend% Call
Node1.merge2(Node2)
But this only changes the handle variable obj and does not change redirect the 'root object' from Node1 to Node2.
Does anyone have a good solution for this, without looping over all properties to find all pointer and manually change the handle variable?
Thanks a lot guys!
Best regards.
Best Answer