How to speed up a code from the Code Profiler Results ?

2 ビュー (過去 30 日間)
Jinsu Kim
Jinsu Kim 2020 年 7 月 14 日
編集済み: Jinsu Kim 2020 年 7 月 14 日
I want to imrpove my code speed, so I did code profiling analysis.
Below is the result of code profiler but I have no idea how to start with these results.
I used ode15s solver, and results seems that bottleneck contained in ode15s solver which means I did not manually write these codes.
The most time consuming lines are:
line 131: Fdel(:,j) = feval(F,Fargs{1:diffvar-1},ydel(:,j),Fargs{diffvar+1:end})
line 148: dFdy = Fdiff * diag(1 ./ del);
line 126 : ydel = y(:,ones(1,ny)) + diag(del);
It accounts on the total computing time 77.1 %, 19.3 % respectively.
Tolerance option change in ode15s solver was not the answer..
In this case, is there any troubleshooting method to enhance the code speed?
Thanks in advances :D


Yair Altman
Yair Altman 2020 年 7 月 14 日
Try to set the "Vectorized" property using the odeset function, before running ode45. Also, specifying the Jacobian in advance (if you know it) can speed up the calculation - set the "Jacobian" and optionally "JPattern" properties of odeset, Take a look at the other options to see if you can give the solver more information about your function - the more information that the solver has, the more likely it is to use an optimized computation.
  1 件のコメント
Jinsu Kim
Jinsu Kim 2020 年 7 月 14 日
編集済み: Jinsu Kim 2020 年 7 月 14 日
Thanks for your reply :)
Unfortunately, I don't know my Jacobian matrix. Anyway, now I'm trying to convert m.file to Cmex file. I hope it works.


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by