필터 지우기
필터 지우기

How to use Simulink.B​us.createM​ATLABStruc​t() in a Matlab-Function

조회 수: 3 (최근 30일)
KIMAE
KIMAE 2017년 5월 18일
댓글: KIMAE 2017년 5월 23일
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...

채택된 답변

Sebastian K
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
  댓글 수: 1
KIMAE
KIMAE 2017년 5월 23일
Thank you, yes this indeed helps. For beginners the interface between Simulink and Matlab is not easy to understand. Seems like any code-generating blocks are not suitable for my problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by