MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply TodayTo resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Asked by Aragorn_ on 8 Dec 2012

Hi everyone,

I am working on an optimization problem which needs to run my model several times and test for different constraints and cost. For this reason I need a model which can be simulated quickly. The solution which I found is to convert the model to a mex file.
I have converted **a part** of the model to mex file... Now when I run this part alone to check if it is faster than m file, I observe that it is faster about 4 times. However, when I plug this mex file to the rest of the model, the result becomes slower....

Does any of you have an idea what can be a possible reason? Thanks in advanced, Reza

*No products are associated with this question.*

Answer by Walter Roberson on 8 Dec 2012

If you have a "clear all" call, get rid of it.

Show 1 older comment

Aragorn_ on 8 Dec 2012

MATLAB.

The model is about a chemical reactor which contains about 1700 ode's.

Walter Roberson on 8 Dec 2012

Could you profile the code to determine where it is spending its time?

## 1 Comment

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/56074#comment_116097

How did you measure the timings? I do not think that anybody can guess the reasons without seeing the code.