What is the difference in goal between C Caller and C Mex ?

30 次查看(过去 30 天)
I have understood that C Caller is used to implement script which is written in C in Simulink, but in S-Function C mex we can do the same thing so what is the difference between them and if they do the same thing which one is better?
  1 个评论
Walter Roberson
Walter Roberson 2020-2-29
Good question. I had not heard of C Caller before.
The main difference I see listed is that it cannot be used for continuous time.
S Function is said to be used for dynamic systems, but at the moment I do not know what the implications of that are. I think S Function can manipulate model state but the C Caller is not designed for that.

请先登录,再进行评论。

回答(1 个)

Dinesh Yadav
Dinesh Yadav 2020-3-3
There is no difference in goal between C Caller and S-functions. Both are used to call C code in simulink. However they differ in terms of simplicity of use and flexibilty they provide.
  • In C caller one can call C code directly and for C++ code one needs to write C wrapper function around C++ code, but in S-function one can call C/C++ code directly.
  • C Caller block is simpler to implement as compared to S-function. For reference type sfundemos in MATLAB command prompt and go through code of any C?C++ S-function and slexCCallerExample to see C Caller example.
  • S-functions have lots of api's as compared to C Caller which makes S-functions more flexible and can be used to implement more complex systems as compared to C Caller blocks. However if one wants to implement basic and simple systems its easier and faster to use C Caller blocks.
  • When calling external C/C++ code or .dll/.so one can perform debugging using Visual Studio etc in S-functions but same cannot be done in C Caller.

Community Treasure Hunt

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

Start Hunting!

Translated by