Microsoft .NET 快速入门
R2026a.NET 接口允许您将 .NET 程序集引入 MATLAB 环境中,从这些程序集中包含的类来构造对象,以及对这些对象调用方法。
MATLAB 支持加载以下 .NET 程序集:
.NET,包括 .NET Core(Microsoft® Windows®、macOS 和 Linux®)
.NET Framework(仅限 Windows)
有关详细信息,请参阅使用 MATLAB 的 .NET 接口的系统要求。有关与 MATLAB 兼容的 .NET 版本的信息,请参阅其他语言的 MATLAB 接口。
要确定您的系统是否具有支持的版本,请使用 NET.isNETSupported 函数。
函数
NET.addAssembly | 将 .NET 程序集添加至 MATLAB |
NET.unloadAssembly | Unload .NET Core assembly from MATLAB (自 R2026a 起) |
NET.isNETSupported | 检查支持的 Microsoft .NET 版本 |
NET.interfaceView | Explicit interface view of .NET object (自 R2023b 起) |
类
NET.Assembly | .NET 程序集成员 |
对象
NET.NetException | 捕获 .NET 异常的错误信息 |
命名空间
NET | MATLAB .NET 接口中的函数和类摘要 |
主题
- 使用 MATLAB 的 .NET 接口的系统要求
使用受支持的 .NET 版本。
- Access Simple .NET Classes
These examples show how to access .NET functionality already installed on your system.
- Build and Load .NET Assembly for MATLAB
Build and load a .NET assembly.
- Save and Load .NET Objects in MAT Files
When you save and load .NET objects in MAT files, MATLAB uses
System.Runtime.Serialization.DataContractSerializerto perform the serialization and deserialization. - Simplify .NET Class Names
Use the MATLAB
importfunction to refer to .NET class names. - 在 MATLAB 函数中使用 import
NET.addAssembly和import函数的使用规范。 - Use .NET Nested Classes and Enumerations
Using reflection to instantiate a nested class or enumeration.
- Handle .NET Exceptions
MATLAB catches exceptions thrown by .NET and converts them into a
NET.NetExceptionobject. - Assembly Is a Library of .NET Classes
An assembly is a collection of types and resources built to work together and form a logical unit of functionality in .NET applications.
- Use .NET from MATLAB
How you can benefit from using .NET from MATLAB.
- Create .NET Objects
How to create a .NET object.
- .NET Terminology
Understanding namespaces and reference and value types.
- Work with Microsoft Excel Spreadsheets Using .NET
This example for Microsoft .NET Framework uses the
Microsoft.Office.Interop.Excel.ApplicationClassclass to create a spreadsheet, copy MATLAB data to it, and then close it. - Work with Microsoft Word Documents Using .NET
This example for Microsoft .NET Framework uses the
Microsoft.Office.Interop.Word.ApplicationClassclass to create a Word document.
疑难解答
Troubleshooting Security Policy Settings from Network Drives
For MATLAB releases R2012b or earlier, call the
enableNETfromNetworkDrive function to create a
MATLAB security policy entry.
.NET features not supported in MATLAB.