I am confused on how to use handle objects as properties in matlab. For example, I defined the following classes:
classdef Page < handleproperties word1; word2;endclassdef Book < handleproperties page1 = Page; page2 = Page;end
Now I instantiate two books:
iliad = Book;odyssey = Book;
If I check if iliad and odyssey are the same:
eq(iliad, odyssey)
I get:
ans = logical 0
So far so good. But if I check if page1 of iliad and odyssey are the same:
eq(iliad.page1, odyssey.page1)
I get:
ans = logical 1
This is not good! It means that if I change page1 of odyssey, page1 of iliad will also change. What am I misunderstanding? How do I deal with this issue?
Best Answer