How to speed up a code from the Code Profiler Results ?
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Yair Altman
on 14 Jul 2020
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.
More Answers (0)
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!