How to use Simulink.Bus.createMATLABStruct() in a Matlab-Function
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Sebastian K
2017-5-22
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!