How can I implement an MATLAB file S-Function into an Embedded MATLAB block?

I have an M ATLAB file S-Function that contains a Derivatives section and an Output section. I want to generate code for my Simulink model but MATLAB file S-Function can not generate code.
I have verified that all the MATLAB functions I use are supported by the Embedded MATLAB block. I can not find a solution to implement the Derivatives section of the MATLAB File S-function into an Embedded MATLAB block.

 採用された回答

MathWorks Support Team
MathWorks Support Team 2021 年 12 月 10 日
編集済み: MathWorks Support Team 2021 年 12 月 13 日

0 投票

Ability to write algorithms (involving derivatives) and then generate code from it, is now available in Matlab System Block in Simulink R2013a and later. For example refer to:
For older releases (i.e., prior to R2013a):
The ability to implement derivatives is not available in Embedded MATLAB, Real-Time Workshop 7.2 (R2008b).
As a workaround, it is possible to use two Embedded MATLAB blocks and one integrator to implement this functionality. The first Embedded MATLAB block computes the derivatives of the states. An Integrator block is used to compute the states and a second Embedded MATLAB block is used to compute the Outputs.
The attached model demonstrates this implementation.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeSimulink Coder についてさらに検索

製品

リリース

R2008a

Community Treasure Hunt

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

Start Hunting!

Translated by