Simulink: how to call .NET static methods properties and instance constructors/properties.methods through matlab user function blocks? And how to pass those values from one to block another one
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Simulink Coder finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!