Main Content

COM Methods

Method Information

You execute, or invoke, COM functions or methods belonging to COM objects. Method names are case-sensitive. You cannot abbreviate them.

To see what methods a COM object supports, use one of the following functions. Each function presents specific information, as described in the table. For information about using a method, refer to your vendor documentation.

FunctionOutput

methodsview

Graphical display of function names and signatures

methods with -full qualifier

Cell array of function names and signatures, sorted alphabetically

methods

Cell array of function names only, sorted alphabetically, with uppercase names listed first

invoke

Cell array of function names and signatures

Call Object Methods

MATLAB® supports the following syntaxes to call methods on an object.

  • By method name:

    outputvalue = methodname(object,'arg1','arg2',...);
  • By dot notation:

    outputvalue = object.methodname('arg1','arg2',...);
    
  • Using explicit syntax:

    outputvalue = invoke(object,'methodname','arg1','arg2',...);
    

The methodsview and methods -full commands show what data types to use for input and output arguments.

You cannot use dot syntax and must explicitly call the get, set, and invoke functions under the following conditions:

  • To access a property or method that is not a public member of the object class.

  • To access a property or method that is not in the type library for the server.

  • To access properties that take arguments. MATLAB treats these properties like methods.

  • To access properties on a vector of objects, use the get and set functions.

    You cannot invoke a method on multiple COM objects, even if you call the invoke function explicitly.

Specify Enumerated Parameters

Enumeration is a way of assigning a descriptive name to a symbolic value. MATLAB supports enumeration for parameters passed to methods under the condition that the type library in use reports the parameter as ENUM, and only as ENUM.

Note

MATLAB does not support enumeration for any parameter that the type library reports as both ENUM and Optional.

Skip Optional Input Arguments

When calling a method that takes optional input arguments, you can skip an optional argument by specifying an empty array ([]) in its place. For example, the syntax for calling a method with second argument arg2 not specified is:

methodname(handle,arg1,[],arg3);

Return Multiple Output Arguments

If a server function supports multiple outputs, you can return any or all those outputs to a MATLAB client.

The following syntax shows a server function functionname called by the MATLAB client. retval is the first output argument, or return value. The other output arguments are out1, out2, ....

[retval out1 out2 ...] = functionname(handle,in1,in2,...);

MATLAB uses the pass-by-reference capabilities in COM to implement this feature. Pass-by-reference is a COM feature; MATLAB does not support pass-by-reference.

Related Examples

More About