Main Content

Load a Global .NET Assembly

This example shows you how to make .NET classes visible to MATLAB®by loading a global assembly using theNET.addAssemblyfunction.

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 anassembly. To work with the class, callNET.addAssemblyto load the assembly into MATLAB. Your vendor documentation contains the assembly name. For example, search theMicrosoft®.NET Frameworkwebsite for theSystem.SpeechSynthesizerclass. The assembly name isSystem.Speech.

NET.addAssembly('System.Speech');

TheSystem.Speechassembly is aglobalassembly. If your assembly is aprivateassembly, use the full path for the input toNET.addAssembly.

TheSystem.DateTime Exampledoes not callNET.addAssemblybecause MATLAB dynamically loads its assembly (mscorlib) at startup.

Note

You cannot unload an assembly in MATLAB.

See Also

Related Topics