MATLAB: Is there any possibility of S-function written in C language calling matlab function library, and if so, then how ? I will appreciate that if someone can tell me.

s-functionsimulink

Is there any possibility of S-function written in C language calling matlab function library, and if so, then how ? I will appreciate that if someone can tell me.

Best Answer

C S-functions are just a special kind of MEX-function, the mexFunction entry-point is defined in simulink.c, which is #included into all S-functions. Please look at the examples in the documentation for mexCallMATLAB for help on converting your C data into mxArrays. Essentially, you need to use one of the mxArray creation functions, and then copy over data from the C variables into the data pointer of the mxArray.