MATLAB: How to decrease the execution time in Matlab

computation time

Hello,
I am wondering if there is a way to speed up the computation time of specific function, such as step or bode in matlab ? If one work with large scale systems, these computations can be quite long.
I tried to look at the parallel computing toolbox but I am not sure if this could help.
Thank you for any help your answer !

Best Answer

No, there is no magic "run faster" setting.
Some algorithms can be parallelized by parfor. Sometimes this does not help, e.g. if all cores are on load already by multi-threading: FFT, SUM and many other commands distribute the work to multiple threads already, such that the available cores are used. Then there is no additional resource left to process in parallel.
You can improve the code e.g. by avoiding repeated calculations, reducing the number of expensive functions (e.g. by writing 1e5 instead of 1*10^5) and by processing the data in column-wise order (then they are neighboring elements in RAM and the processing is faster). There are many more methods to accelerate algorithms and Matlab code. Use the profiler to find the bottleneck of the code and then post it here to get specific suggestions.