S-function or embedded MATLAB function

1 Ansicht (letzte 30 Tage)
Michael Joslin
Michael Joslin am 1 Feb. 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.

Akzeptierte Antwort

Kaustubha Govind
Kaustubha Govind am 1 Feb. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Coder finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by