Hi,
I'm looking for a way to make proper .NET calls from Simulink through matlab. I'm pretty aware that this code is not going to be compiled and therefore only interpreted on the matlab side. Also, I'm wondering how can I pass some reference values through one block to another one.
NET.addAssembly('System.Speech');obj = System.Speech.Synthesis.SpeechSynthesizer;obj.Volume = 50;Speak(obj,'You can use .NET Libraries in MATLAB')
The problem is that, for instance, this code is not really usable as such as it is in a Simulink matlab user-function block, I need to use whether code.extrinsic or feval .
I successfully managed to use feval and coder.extrinsic for callings methods but I cannot find a way to get or set the values on properties such as:
function speechSynthesizer = Initialize()%#codegen
feval('clc');feval('clear');feval('NET.addAssembly', 'System.Speech');speechSynthesizer = feval('System.Speech.Synthesis.SpeechSynthesizer');volume = speechSynthesizer.Volume;speechSynthesizer.Volume = volume / 2;feval('Speak', speechSynthesizer, 'Im using .NET from simulink');
Also I do not really now how to pass the speechSynthesizer as the return value since the matlab function block is quite restrictive.
Any idea / workaround to make it work?
Best Answer