Search code examples
matlabsimulinksymbolic-computations-function

Is there a procedure to convert m-file-function to C(or MEX) S-function?


I have a simple function written as MATLAB code. For example:

function s = sum_inputs(a,b)

s = a+b;

This function derives from matlabFunction command application using a symbolic expression. I could like to convert it to S-Function for speed-up performance, for example to a C S-function, MEX S-Function, etc instead of using it in MATLAB S-function block or Interpreted MATLAB block. Thanks


Solution

  • Don't use a C or MEX S-Function for something as simple as that. Use a MATLAB Function block instead. It uses code generation so is much faster than an interpreted MATLAB Function block.