Now we'll learn how to develop a custom S-function block using the C language. A basic knowledge of the C syntax is required.
The C language offers some advantages over MATLAB's scripting language:
It is the most-used language to develop (hard) real-time systems
It is one of the most popular languages, if not the most popular
C executables offer unparalleled performance with respect to MATLAB scripts
C S-functions can be developed without having MATLAB installed (but you'd still need the external headers and libraries)
Legacy C code can be easily ported to S-function blocks and used in Simulink
C++ compilers can be used, giving access to some powerful C++ frameworks like Qt
C MEX S-functions are programmed in C/C++ and built with the mex
tool, which comes with MATLAB.
They are compiled as dynamically linked libraries on Windows platform, and as shared objects on UNIX/Linux platform, using the available compiler.
Tip
For a list of supported compilers, go to http://www...