Get information of property type of object properties (i.e. 'dependent')
古いコメントを表示
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
採用された回答
その他の回答 (3 件)
Daniel Shub
2012 年 3 月 1 日
0 投票
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 件のコメント
Staffan
2012 年 3 月 13 日
Daniel Shub
2012 年 3 月 14 日
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
2012 年 3 月 13 日
0 投票
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 件のコメント
Daniel Shub
2012 年 3 月 14 日
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
2012 年 3 月 14 日
0 投票
1 件のコメント
Daniel Shub
2012 年 3 月 14 日
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.
カテゴリ
ヘルプ センター および File Exchange で Argument Definitions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!