| Contents | Index |
| On this page… |
|---|
What Is the Microsoft .NET Framework? Benefits of the MATLAB .NET Interface Why Use the MATLAB .NET Interface? What's the Difference Between the MATLAB .NET Interface and MATLAB Builder NE? |
The Microsoft .NET Framework is an integral Windows component that provides a large body of precoded solutions to common program requirements, and manages the execution of programs written specifically for the Framework.
MATLAB supports the .NET Framework on the Windows platform only.
The MATLAB .NET interface enables you to:
Create instances of .NET classes.
Interact with .NET applications via their class members.
Use the MATLAB .NET interface to take advantage of the capabilities of the Microsoft .NET Framework. For example:
You have a professionally developed .NET assembly and want to use it to do certain operations, such as access hardware.
You want to leverage the capabilities of programming in .NET (for example, you have existing C# programs).
You want to access existing Microsoft-supplied classes for .NET.
The speech synthesizer class, available in .NET Framework Version 3.0 and above, is an example of a ready-to-use feature. Create the following Speak function in MATLAB:
function Speak(text)
NET.addAssembly('System.Speech');
speak = System.Speech.Synthesis.SpeechSynthesizer;
speak.Volume = 100;
Speak(speak,text);
endFor an example rendering text to speech, type:
Speak('You can use .NET Libraries in MATLAB');MATLAB supports the .NET features C# supports, except for the limits noted in the following table.
| Features Not Supported in MATLAB |
|---|
| Cannot use ClassName.propertyname syntax to set static properties. Use NET.setStaticProperty instead. |
| Unloading an assembly |
| Passing a structure array, sparse array, or complex number to a .NET property or method |
| Subclassing .NET classes from MATLAB |
| Accessing nonpublic class members |
| Displaying generic methods using methods or methodsview functions. For a workaround, see Display .NET Generic Methods Using Reflection. |
| Creating an instance of a nested class. For a workaround, see Working With Nested Classes. |
| Saving (serializing) .NET objects into a MAT-file |
| Creating .NET arrays with a specific lower bound |
| Creating ragged (nonrectangular) .NET arrays |
| Concatenating multiple .NET objects into an array |
| Implementing interface methods |
| Hosting .NET controls in figure windows |
| Casting operations |
| Calling constructors with ref or out type arguments |
| Using System.Console.WriteLine to write text to the command window |
| Pointer type arguments, function pointers, Dllimport keyword |
| .NET remoting |
| Using the MATLAB: (colon) operator in a foreach iteration |
| Adding event listeners to .NET events defined in static classes |
| Handling .NET events with signatures that do not conform to the standard signature |
| Creating empty .NET objects |
The MATLAB .NET interface is for MATLAB users who want to use .NET assemblies in MATLAB.
MATLAB Builder™ NE (previously called .NET Builder) packages MATLAB functions so that .NET programmers can access them. It brings MATLAB into .NET applications. For more information about this product, see the product link at http://www.mathworks.com/help/.
The MATLAB interface to .NET is available on the Windows platform only.
You must have the Microsoft .NET Framework installed on your system.
The MATLAB interface supports the features of the .NET Framework Version 2.0, and works with Version 2.0 and its compatible versions (Versions 3.0 and 3.5). MATLAB supports loading Framework Version 4.0 assemblies if you have Version 4.0 installed on your system. However, Version 4.0-specific features have not been tested.
To use a .NET application, refer to your vendor's product documentation for information about how to install the program and for details about its functionality.
MATLAB provides a configuration file, MATLAB.exe.config, in your matlabroot/bin/arch folder. With this file, MATLAB loads the latest core assemblies available on your system. You can modify and use the configuration file at your own risk. For additional information on elements that can be used in the configuration file, please visit the Configuration File Schema for the .NET Framework Web page at http://msdn.microsoft.com/en-us/library/1fk1t1t0.aspx.
For an example of using .NET in MATLAB, see:
For detailed information, see:
For a complete description of the .NET Framework, you need to consult outside resources.
One source of information is the Microsoft Developer Network. Search the .NET Framework Development Center at http://msdn.microsoft.com/en-us/netframework/aa496123 for the term ".NET Framework Class Library". The .NET Framework Class Library is a programming reference manual. Many examples in this documentation refer to classes in this library. There are different versions of the .NET Framework documentation, so be sure to refer to the version that is on your system. See System Requirements for information about version support in MATLAB.
![]() | Using .NET Libraries from MATLAB | Getting Started with .NET | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |