When you use isa
, MATLAB returns true
if the class name of the first input argument is either the specified class, or
a subclass of the specified class. When you use strcmp
, MATLAB returns
true
only if the input arguments match, and therefore
subclasses are not considered a match.
If you want a comparison to return true
only if the input
arguments match, leave your code as is.
If you want a comparison to return true
if the class of the
first input argument matches, or is a subclass of the specified class, use
isa
.
For example, change code such as this,
strcmp(class(x),'className');
to this:
isa(x,'className');