MEX-Function execution time issue in Simulink model
I am working on integrating a MEX function into a Simulink model to protect the source code of an algorithm from direct visibility. To achieve this, I converted the original MATLAB function into a MEX function, which I then call within a MATLAB Function block using the coder.extrinsic command.
During my testing, I’ve observed that the MEX function executes at each simulation step and is significantly slower compared to the original MATLAB function, resulting in a much higher overall simulation time.
I have several questions and would appreciate insights from the community:
Why might the MEX function be performing slower than the MATLAB function within the Simulink environment?
How does Simulink handle MEX functions during simulation and compilation?
What are the best practices or correct methods for integrating a MEX function into a Simulink model to ensure optimal performance?
Any detailed explanations or guidance on troubleshooting and improving the performance of MEX functions in Simulink would be highly appreciated. Thank you!I am working on integrating a MEX function into a Simulink model to protect the source code of an algorithm from direct visibility. To achieve this, I converted the original MATLAB function into a MEX function, which I then call within a MATLAB Function block using the coder.extrinsic command.
During my testing, I’ve observed that the MEX function executes at each simulation step and is significantly slower compared to the original MATLAB function, resulting in a much higher overall simulation time.
I have several questions and would appreciate insights from the community:
Why might the MEX function be performing slower than the MATLAB function within the Simulink environment?
How does Simulink handle MEX functions during simulation and compilation?
What are the best practices or correct methods for integrating a MEX function into a Simulink model to ensure optimal performance?
Any detailed explanations or guidance on troubleshooting and improving the performance of MEX functions in Simulink would be highly appreciated. Thank you! I am working on integrating a MEX function into a Simulink model to protect the source code of an algorithm from direct visibility. To achieve this, I converted the original MATLAB function into a MEX function, which I then call within a MATLAB Function block using the coder.extrinsic command.
During my testing, I’ve observed that the MEX function executes at each simulation step and is significantly slower compared to the original MATLAB function, resulting in a much higher overall simulation time.
I have several questions and would appreciate insights from the community:
Why might the MEX function be performing slower than the MATLAB function within the Simulink environment?
How does Simulink handle MEX functions during simulation and compilation?
What are the best practices or correct methods for integrating a MEX function into a Simulink model to ensure optimal performance?
Any detailed explanations or guidance on troubleshooting and improving the performance of MEX functions in Simulink would be highly appreciated. Thank you! simulink, mex function, coder.extrinsic, simulation speed, mex compiler, execution time, matlab compiler MATLAB Answers — New Questions