Main Content



从 MATLAB® 访问 COM 组件

Microsoft® 组件对象模型 (COM) 提供了一个将可重复使用的二进制软件组件集成到应用程序中的框架。由于组件是使用编译代码实现的,因此可以采用支持 COM 的编程语言来编写源代码。由于可以简单地交换组件,而无需重新编译整个应用程序,因此简化了应用程序升级。此外,组件位置对应用程序是透明的,因此可以将组件重新放置到单独的进程甚至远程系统中,而不必修改应用程序。

或者,考虑使用 Microsoft .NET Framework。

MATLAB 仅在 Microsoft Windows® 平台上支持 COM 和 .NET Framework 集成。


actxserver创建 COM 服务器
eventlisteners列出与 COM 对象事件关联的事件处理程序函数
registerevent在运行时关联 COM 对象事件的事件处理程序
unregisterallevents注销与 COM 对象事件关联的所有事件处理程序
unregisterevent在运行时注销与 COM 对象事件关联的事件处理程序
iscom确定输入是否为 COM 对象
isevent确定输入是否为 COM 对象事件
isinterface确定输入是否为 COM 接口




Microsoft Office

将数据写入 Excel 电子表格

此示例显示如何将 MATLAB 矩阵写入 Excel® 电子表格。有关将 MATLAB 数据导出到 Microsoft Excel 电子表格的备选方法,请参阅电子表格中的函数和示例。

使用 Excel 作为自动化服务器读取电子表格数据

此示例说明如何使用 COM 自动化服务器从 MATLAB 访问另一个应用程序。该示例创建了用于访问 Microsoft Excel 文件中的数据的用户界面。如果您在应用程序中未使用组件对象模型 (COM),请参阅电子表格中的函数和示例,以获取将 Excel 电子表格数据导入 MATLAB 的备选方法。

Change Cursor in Spreadsheet

This example shows how to change the cursor icon in an Excel® spreadsheet.

Change Row Height in Range of Spreadsheet Cells

This example shows how to change the height of a row, defined by a Range object, in a spreadsheet.

Insert Spreadsheet After First Sheet

This example shows how to skip an optional input argument in the Excel Add method, used to insert a sheet into a workbook.

Connect to Existing Excel Application

This example shows how to read data from an open file, weekly_log.xlsx, in MATLAB.

Display Message for Workbook OnClose Event

This example shows how to handle a COM interface event, how to set up an event in a Microsoft Excel workbook object, and how to handle its BeforeClose event.

Explore COM Objects

Learn about a COM object using MATLAB commands.


MATLAB COM Integration

COM concepts and an overview of COM support in MATLAB.

Get Started with COM

Examples that show how to use COM interface with MATLAB.

Register Servers

Before using COM objects, you must register their servers.

创建 COM 对象

如何创建 Microsoft 控件和 COM 服务器对象。

Handle COM Data in MATLAB

Pass data to and handle data from a COM object.

COM Object Properties

List property names and set values, work with multiple objects and properties, use the Property Inspector, use enumerated values and custom properties.

COM Methods

You execute, or invoke, COM functions or methods belonging to COM objects.

COM Events

Respond to events, write event handlers.

COM Event Handlers

Use registerevent to register server events.

Save and Delete COM Objects

Use these MATLAB functions to save and restore the state of a COM control object.

COM Object Interfaces

Use COM interfaces.

COM Collections

COM collections are a way to support groups of related COM objects that can be iterated over.

Supported Client/Server Configurations

COM client-server configurations in MATLAB.

MATLAB Application as DCOM Client

Distributed Component Object Model (DCOM) is a protocol that allows clients to use remote COM objects over a network.


MATLAB COM Support Limitations

Microsoft does not support loading 32-bit DLLs or in-process COM servers into a 64-bit application, or conversely.

Interpreting Argument Callouts in COM Error Messages

When a MATLAB client sends a command with an invalid argument to a COM server application, the server sends back an error message in the following format.