S-function or embedded MATLAB function

1 visualización (últimos 30 días)
Michael Joslin
Michael Joslin el 1 de Feb. de 2011
I am creating various subsystems for a vehicle control system and I have come to a point where I would like to implement some blocks written by myself. I have been teaching myself C++ and I would be able to create an S-function if needed but I also know how to program with MATLAB so an embedded MATLAB function is also possible. My question is which of these two options is more efficient in terms of computing power and speed? Keep in mind that the program I'm writing is going to be flashed to a dSPACE microautobox.

Respuesta aceptada

Kaustubha Govind
Kaustubha Govind el 1 de Feb. de 2011
In terms of performance, I don't believe that there is a significant difference between Embedded MATLAB Function and C/C++ S-functions (although I suspect S-functions are leaner). However, there are a couple of differences I can think of, otherwise:
  1. Since you intend to generate embedded code for these blocks, S-functions will require you to write TLC scripts, whereas, Embedded MATLAB takes care of code generation for you.
  2. S-functions allow you much more control over your block, such as maintaining state vectors and customizing block callback methods such as mdlEnable, mdlUpdate, mdlZeroCrossings, etc. Embedded MATLAB blocks have only one function (which is the equivalent of a combined mdlUpdate and mdlOutputs).
In summary, the choice is between speed of development and control over block implementation.

Más respuestas (0)

Categorías

Más información sobre Simulink Coder en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by