Documentation Center

  • Trial Software
  • Product Updates

Load a Global .NET Assembly

This example shows you how to make .NET classes visible to MATLAB® by loading a global assembly using the NET.addAssembly function.

The speech synthesizer class (available in .NET Framework Version 3.0 and above) provides ready-to-use text-to-speech features. For example, type:

NET.addAssembly('System.Speech');
speak = System.Speech.Synthesis.SpeechSynthesizer;
speak.Volume = 100;
speak.Speak('You can use .NET Libraries in MATLAB');

The speech synthesizer class, like any .NET class, is part of an assembly. To work with the class, call NET.addAssembly to load the assembly into MATLAB. Your vendor documentation contains the assembly name. For example, search the Microsoft® .NET Framework Web site for the System.SpeechSynthesizer class. The assembly name is System.Speech.

NET.addAssembly('System.Speech');

The System.Speech assembly is a global assembly. If your assembly is a private assembly, use the full path for the input to NET.addAssembly.

The System.DateTime Example does not call NET.addAssembly because MATLAB dynamically loads its assembly (mscorlib) at startup.

    Note:   You cannot unload an assembly in MATLAB.

For more information, see:

Was this topic helpful?