Info

This question is closed. Reopen it to edit or answer.

How to make my Simulink program with m-code run faster

1 view (last 30 days)
In my simulink program I have a call to an m-file in an "interpreted matlab function". Calling this m-file takes a lot of time. Are there any faster ways to use the same code I'm using in the m-file. Just copy/paste of the code in a matlab (embedded) function didn't work for me. Are there any suggestions?

Answers (1)

Walter Roberson
Walter Roberson on 7 Dec 2015
There are various techniques to optimize .m functions. You would usually start by profiling the code execution.
Generally for higher performance than that you would use an (embedded) MATLAB Function block, for which you would need to adapt the code. You can seldom simply copy and paste into such a block, but the work is not necessarily a lot more than adding hints about the expected matrix sizes and types. However, not all routines can be accelerated with such a block. A lot depends on your code. It is difficult to answer without seeing your code.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!