Load a Global .NET Assembly
This example shows you how to make .NET classes visible to MATLAB®by loading a global assembly using theNET.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 anassembly. To work with the class, callNET.addAssembly
to load the assembly into MATLAB. Your vendor documentation contains the assembly name. For example, search theMicrosoft®.NET Frameworkwebsite for theSystem.SpeechSynthesizer
class. The assembly name isSystem.Speech
.
NET.addAssembly('System.Speech');
TheSystem.Speech
assembly is aglobalassembly. If your assembly is aprivateassembly, use the full path for the input toNET.addAssembly
.
TheSystem.DateTime Exampledoes not callNET.addAssembly
because MATLAB dynamically loads its assembly (mscorlib
) at startup.
Note
You cannot unload an assembly in MATLAB.