isprop for custom classes

3 vues (au cours des 30 derniers jours)
Dmitry Borovoy
Dmitry Borovoy le 12 Sep 2011
Why isprop doesn't work for custom classes in Matlab versions earlier than 2011a? Even help shows that this feature works only for COM object. So how to check is property a property of my class? sorry for my english...

Réponse acceptée

Daniel Shub
Daniel Shub le 14 Sep 2011
I don't know why TMW only implemented isprop for custom classes in r2011a, but it is pretty easy to work around. To test if a string y is a property of an object obj:
x = metaclass(obj)
tf = ismember(y, {x.PropertyList.Name});
This doesn't do any error checking on obj or y. If you have r2011a you can see the copyrighted source code of TMW's implementation of isprop.
edit isprop
  1 commentaire
Dmitry Borovoy
Dmitry Borovoy le 25 Sep 2011
sorry, was offline

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Customize Object Indexing dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by