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.

 采纳的回答

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 Exchange 中查找有关 Simulink Coder 的更多信息

产品

版本

R2008a

Community Treasure Hunt

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

Start Hunting!

Translated by