MATLAB: MATLAB Function Versus MATLAB S-Function (processing speed)
matlab functions-functionsimulationsimulink
Simulink
Why block MATLAB FUNCTION is slower than block MATLAB S-Function in may model?
The task is the same.
Best Answer
When you say "MATLAB Function" block, do you mean theEmbedded MATLAB Function block (the block icon has the MathWorks logo on it), or theInterpreted MATLAB Function block? Also, it would help if you post your code. Some functions (like FFT) may be faster if run in interpreted mode in MATLAB than with the Embedded MATLAB Function block, which generates C-code from the MATLAB functions. Some MATLAB implementations are highly optimized, and hence perform better than the generated C code.
If you want to write MATLAB code that runs fast, you can use the MATLAB Function Block (previously called Embedded MATLAB Function block). Or you also have the option to write a C-Mex s-function.
I wrote posts about including MATLAB code in a simulation:
Best Answer