S-function or embedded MATLAB function

6 次查看(过去 30 天)
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.

采纳的回答

Kaustubha Govind
Kaustubha Govind 2011-2-1
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by