MATLAB Answers

0

Speed up simulation

Hello,
I've read some of the questions posted on mathworks regarding this subject, but still I want to speed up the simulation for example by 10 times or 100 times.
The reason to do this is because I'm using a signal builder with lots of values used for testing a model and writing the outputs in an excel and to do this for all the values would take about 7h...
Thanks in advance, Alex

  0 Comments

Sign in to comment.

1 Answer

Answer by Kaustubha Govind on 26 Jun 2012
 Accepted Answer

There are several techniques for improving your Simulink model's performance. Please see these articles:
Also, you mentioned writing outputs to an Excel file - do you do this at the end of simulation or at each time step? I'm assuming you use the XLSWRITE command?

  3 Comments

Alexandru on 26 Jun 2012
The inputs are always changing so yes I'm using a Level 2 S-Function to write the results with the XLSWRITE. But I could try to write the outputs in a cell array and write them at the end in the excel...
K E
on 26 Jun 2012
You may also find this blog entry helpful for making sure you are not wasting time with the wrong step size, http://blogs.mathworks.com/seth/2012/06/04/the-most-useful-command-for-debugging-variable-step-solver-performance/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+SethOnSimulink+%28Seth+on+Simulink%29
Kaustubha Govind on 27 Jun 2012
Nice tip KE!
@Alexandru: XLSWRITE opens and closes the Excel file at each time step, which I suspect may be slowing down your simulation. You could try using the Simulink Profiler to see where the slowdown is coming from before investing in improving the Excel writing part. If that S-function turns out to be the culprit, what you need is to only open once, write all your data and close it. You can either do this in your S-function by controlling the Excel COM connection (relevant function is: http://www.mathworks.com/help/techdoc/ref/actxserver.html) so that you open the file in setup() and close in terminate(). Or if you prefer to stick with XLSWRITE, just do it at the end of simulation.

Sign in to comment.