Matlab function with initial long execution time
Show older comments
Hello,
When I run a function handle its execution time is initially very long but in the second, third, etc runs its execution time is normal (sometimes, however, I see that the lnog initial execution time will happen again in later runs but this does not happen very frequently).I have seen this problem when I work with symbolic expressions but did not expect to see this in matlabfunctions. I would like to know whether there is a way to avoid this? Or, is there something like 'loading the file' (or similar concepts) prior to executing the matlab function to avoid this?
In the following, you see an example about my question (the matlab function EZ_CC_3_11 is attached).
n=10;
Dm0=rand(1,n);Dm1=rand(1,n);Dm0=rand(1,n);Dm2=rand(1,n);Dm3=rand(1,n);Ds0=rand(1,n);Ds1=rand(1,n);Ds2=rand(1,n);Ds3=rand(1,n);
tic;EZ_CC_3_11(Dm0,Dm1,Dm2,Dm3,Ds0,Ds1,Ds2,Ds3);toc;
Elapsed time is 111.170418 seconds.
tic;EZ_CC_3_11(Dm0,Dm1,Dm2,Dm3,Ds0,Ds1,Ds2,Ds3);toc;
Elapsed time is 0.033134 seconds.
tic;EZ_CC_3_11(Dm0,Dm1,Dm2,Dm3,Ds0,Ds1,Ds2,Ds3);toc;
Elapsed time is 0.029289 seconds.
Thanks,
Babak
Accepted Answer
More Answers (0)
Categories
Find more on Build Configuration 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!