How to check if a class has a specific base class in Matlab
I define a class in Matlab that is a subclass of another, for example:
classdef SpecificLimit < BaseLimit
% Private properties section
properties (SetAccess = private, GetAccess = private)
options;
end
% Public section
methods (Access = public)
% ...
end
end
Now I have a variable named r
and I want to check if this variable is an instance of a class that has BaseLimit
as a base class (I have a lot of them). Is there an easy way to do this? I've read about meta.class
, but I haven't found a way to accomplish this check.
I am using Matlab r2014a.
+3
source to share
2 answers
You can use the superclasses function
Something like:
any ( strcmp ( superclasses ( 'SpecificLimit' ), 'BaseLimit' ) )
+1
source to share