Main Content


Determine if object has specified method



tf = ismethod(obj,methodName) returns logical 1 (true) if the specified methodName is a nonhidden, public method of object obj. Otherwise, ismethod returns logical 0 (false). The methodName argument is the name of the method specified as a character vector or a string scalar.

ismethod does not take class names specified as character vectors or strings as the first argument to identify a class. To list the methods defined by a class using its class name, use the methods function.


Test for Equality

Determine if objects support equality testing before executing code.

if ismethod(obj1,'eq') && ismethod(obj2,'eq')
   tf = obj1 == obj2;

Input Arguments

collapse all

Object of class defining method, specified as an instance of the class.

Data Types: object

Name of the method potentially defined by the class of the first input argument, specified as a character vector or string scalar.

Data Types: char | string

Output Arguments

collapse all

True if class of object define specified method, returned as a 1 or 0 or data type logical.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a