Get information of property type of object properties (i.e. 'dependent')
Show older comments
Hello,
I often use a subfunction to compare if two objects are equal. This subfunction simply compares every property for same numbers, strings and so on. My objects have some dependent properties which need a lot of time to be calculated. It would not be necessary to compare the dependent properties to see if objects are equal.
Is there a possibility to find out, if properties are "real" properties before accessing them?
Thaks for any help!
Staffan
Accepted Answer
More Answers (3)
Daniel Shub
on 1 Mar 2012
0 votes
Isn't the current behavior of your subfunction what isequal does? Why not overload isequal for your class? Presumably in the context of your classdef you know which properties are dependent.
2 Comments
Staffan
on 13 Mar 2012
Daniel Shub
on 14 Mar 2012
Your other answer seems to suggest that you no longer believe that isequal only works with numbers. If this is the case, please consider editing (requires deleting and reposting) your comment to help others in the future.
per isakson
on 13 Mar 2012
0 votes
With R2010b helps says:
When comparing handle objects, use eq or the == operator to test whether objects are the same handle. Use isequal to test if objects have equal property values, even if those objects are different handles.
1 Comment
Daniel Shub
on 14 Mar 2012
I think is should be a comment to my answer, and not a new answer. Also, why no love with an upvote. In this case I think an upvote could help others in the future realize the comment by Staffan isn't correct.
Staffan
on 14 Mar 2012
0 votes
1 Comment
Daniel Shub
on 14 Mar 2012
I think this should either be a comment to per's answer or a comment to my answer. Your "enhancements" seem to be asking a much different question. I think it would probably be reasonable to post your function as none of the answers provide working code segments.
Categories
Find more on Performance and Memory in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!