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.

 Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 10 de Dic. de 2021
Editada: MathWorks Support Team el 13 de Dic. de 2021
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.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Centro de ayuda y File Exchange.

Productos

Versión

R2008a

Community Treasure Hunt

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

Start Hunting!

Translated by