How to use Simulink.Bus.createMATLABStruct() in a Matlab-Function
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have got a non-virutal Bus defined in Simulink (exported / saved to the file "testBusStruct.mat"). This Bus is connected to a Matlab-Function. In that Matlab-Function I want e.g. to return instances of this struct to put them onto the Bus.
Unfortunately, Simulink.Bus.createMATLABStruct('BusObject') does not work. The Matlab-Function complains already about "Simulink" which is not found. If I include Simulink as extrinsic (which is probably not the right way to use it), then it complains about "Dot notation on function call is not allowed as return value" which does not make any sense at all. The BusObject, however, is already visible in the Matlab Workspace as variable, but I cannot allocate a new struct based on the Bus-structure.
I already tried: %coder.extrinsic('Simulink.Bus') %coder.extrinsic('Simulink.Bus.createMATLABStruct') %temp = load('testBusStruct.mat') currentStepBusStruct = Simulink.Bus.createMATLABStruct('BusObject') %currentStepBusStruct = BusObject
Nothing helps, and I cannot find the solution on your website. The documentation for Simulink.Bus.createMATLABStruct does NOT describe its limitations and its scope - according to the documentation it should work...
0 Kommentare
Akzeptierte Antwort
Sebastian K
am 22 Mai 2017
Hi there,
The MATLAB Function block offers limited support for classes and functions that are available to users in the base MATLAB environment. This is because the MATLAB Function block is typically used with code generation, and not all MATLAB methods and functions are supported for code generation.
For instance, if you take a look at the documentation page that lists the functions and objects that are supported for code generation, you will notice that none of the Simulink API objects and functions (e.g., Simulink.Bus) are listed here.
For creating structures in a MATLAB Function block, please refer to the relevant documentation page that describes the recommended workflow.
I hope this helps.
Sebastian
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!