Call MATLAB from .NET
MATLAB Engine API for .NET provides an interface between .NET programming languages and MATLAB. This API enables programs to launch MATLAB, evaluate MATLAB functions with arguments, and exchange data between MATLAB and .NET programs.
To access .NET libraries directly from MATLAB instead, see Call .NET from MATLAB.
If you need to maintain existing .NET programs created for MATLAB R2022a or earlier that work with the Microsoft® Component Object Model (COM), see Write COM Applications to Work with MATLAB.
Functions
Classes
Topics
Set Up and Build Engine Applications
- Elements of a .NET Engine Program
Get started with MATLAB Engine API for .NET.
Start MATLAB from .NET Application
- Start MATLAB Session from .NET
Start a .NET engine session synchronously or asynchronously, and pass startup options to MATLAB. - Connect .NET Application to Running MATLAB Session
Connect the .NET engine to a running MATLAB session that has been started as or converted to a shared session.
Data Mapping
- Pass .NET Data Types to MATLAB Functions
Convert .NET data to MATLAB data. - Handle MATLAB Data in .NET Applications
Convert MATLAB data to .NET data. - Strongly Typed Interface for C#
A strongly typed interface enforces a strict data type mapping between MATLAB and C# to use in .NET applications.
Call MATLAB Functions from .NET
- Execute MATLAB Functions from .NET
Pass variables to MATLAB function calls and return values to .NET applications. - Use MATLAB Structures in .NET
Define MATLAB structure data types in .NET using theMathWorks.MATLAB.Types.MATLABStruct
class. - Use MATLAB Dictionary Objects in .NET
These examples show how to pass dictionary variables to MATLAB function calls and return dictionary values to .NET applications. - Use MATLAB Handle Classes in C#
Integrate MATLAB handle classes with C# applications.
Troubleshooting
MathWorks.MATLAB.Exceptions Exception Classes for .NET
The MathWorks.MATLAB.Exceptions
namespace contains the
exception classes for the .NET engine.