Info
This question is closed. Reopen it to edit or answer.
save referenced "places" of an object
1 view (last 30 days)
Show older comments
Hi, i have objects of a class "Point" and objects of a class "Vector". Both subclasses of handle. Points will be referenced/stored as objects in vector-objects.
For example:
>> vector_a.x=Point_1_X
>> vector_a.y=Point_1_Y
>> vector_a.z=Point_1_Z
and so on with way more points and vectors.
My question is: Points can be referenced in different vectors. And i'd like to store the name of the vector objects, where points get referenced.
In the example:
After saying
>> vector_a.x=Point_1_X
the string "vector_a" should get stored automatically in the property of Point
>> Point_1_X.contained
ans = 'vector_a'
So, later, all points have to know (in their property "contained") in which vectors they are referenced.
How can I do that? Is there an built-in or a smart way to do that?
_
Thanks for your help. Hope i explained the question properly.
0 Comments
Answers (1)
Matt J
on 15 May 2015
You can overload the class' subsasgn method and use the INPUTNAME command there to get the string 'vector_a'. However, you will have to decide what to do when the assignment is to an object that does not have a name, as for example, when you do
vector_a{1}.x=whatever
1 Comment
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!