MATLAB: How to call a method in the .NET assembly from Simulink 7.3 (R2009a)

cMATLABsimulink

I want to call a function that is part of a .NET assembly from my Simulink model. I would like to know if this is possible.

Best Answer

Starting in MATLAB 7.8 (R2009a), the MATLAB interface to the .NET framework allows .NET assemblies to be loaded into MATLAB, create instances of .NET objects in the MATLAB workspace and to call methods from .NET assemblies.
In order to call a method from a .NET assembly in Simulink, utilize the "MATLAB Function" block in Simulink. Attached is an example showing how to call a method from a .NET assembly via a MATLAB function called from the MATLAB Function Simulink block.
In order to run the example, implement the following steps:
1. Save the attached files in a directory
2. In MATLAB 7.8 (R2009a), change your current working directory to the directory where you stored the files.
3. Open the .mdl file
4. Start simulation