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

조회 수: 30 (최근 30일)
Muhammad Alhaddad
Muhammad Alhaddad 2020년 2월 29일
댓글: Walter Roberson 2020년 3월 3일
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.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 3월 3일
Thanks for the summary!
Which of the two has lower overhead? I suspect it would be C Caller?

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by