Why do I get an error when generating code from an Interpreted MATLAB Function block? And what is the difference between this block and a MATLAB Function block?
조회 수: 13 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2020년 12월 15일
편집: MathWorks Support Team
2025년 2월 3일
We have a model that consists of an Interpreted MATLAB Function block. When we tried to generate code from Simulink coder, we are receiving an error saying that:
Simulink Coder Error in block: "myModel/Interpreted MATLAB Function", block type "MATLABFcn": Not yet supported by Simulink Coder
What is an alternative? What is the difference between MATLAB Function block and Interpreted MATLAB Function block?
채택된 답변
MathWorks Support Team
2025년 1월 24일
편집: MathWorks Support Team
2025년 2월 3일
This is expected since the Interpreted MATLAB Function block is not supported for code generation. To work around the issue, use a MATLAB Function block instead. To access the release-specific documentation for MATLAB R2020b, please run the following command in the MATLAB command window:
>> web(fullfile(docroot, 'simulink/slref/matlabfunction.html'))
You can execute the following command at the MATLAB Command prompt to get the Block Support Table, which displays the different blocks supported for code generation:
>> showblockdatatypetable
There, it is mentioned to use the MATLAB Function block as an alternative to the Interpreted MATLAB Function block for code generation.
Differences between MATLAB Function and Interpreted MATLAB Function block:
The MATLAB Function block is compiled before run-time (R2014b and earlier, it generates C code and compiles; R2015a and later, it is compiled just-in-time). The Interpreted MATLAB Function block uses the MATLAB interpreter to execute an existing MATLAB function.
If you're just running simulations on your desktop, there won't be much noticeable differences. However, if you're generating code from your model, you cannot do so with the Interpreted MATLAB Function block. Also, the MATLAB Function block is more customizable, as you have more control over the properties (size/data type/data scope) of all the variables, you can create tunable parameters in the blocks, etc.
In summary, the MATLAB Function block is much more flexible and we would recommend using it in most situations. The Interpreted MATLAB Function block can be easier to set up if you already have an existing function, and it lets you use the full range of MATLAB as long as you're using the model strictly for desktop simulation.
For additional information regarding the current release, please follow the link below:
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!