I have a cell array of strings with names of files that match certain criteria. Now want to test if each of these strings is 1) the name of a class and 2) if it is a class, is it a subclass of the MATLAB Unit Test class. How can I do this?
MATLAB: How to check if a string is the name of a custom subclass
inheritanceMATLABmcossubsuperunittest
Related Question
- Are .m files in a subfolder of a class folder considered methods of that class
- Can I specify a package of classes as allowable subclasses
- How to remove a dynamic property from a class
- Do I get an error if I reorder the fields in a MATLAB class object
- How to modify private properties from inside a class
- Can I query the properties of a custom class using the ‘get’ method
- Super class get callers name
Best Answer
You can use a combination of the "exist", "ismember", and "superclasses" functions. This lets you see if a given string represents a class name and whether that class is a subclass of the MATLAB Unit Test superclass. The general syntax is as follows:
In this both "classname" and "superclassName" are strings. This will return logical 1 if "classname" is both a class and "superclassName" appears in the set of its superclasses. This can handle many levels of inheritance, since the "superclasses" function does not only include direct superclasses.