Does not using 'clc' command increase the computation time?

1 次查看(过去 30 天)
Hello, I am running a code that test different parameters performance on an algorithm and I write results to command line as below. However the program starts fast but than begin to slower and slower nearly after 30000 steps. Normally it does samething, and there is no workload that comes from different parameter. Dou you know what can cause such problems? Thank you.
A part of code:
for mi=1:length(matris_size)
for gi=[2 3 4]
gauss_f=f_gauss_dagilimi(gauss(gi).n, gauss(gi).sigma, gauss(gi).window_size);
for peak_threshold=[0.01 : 0.2: 1.41 ]
for en_buyuk_kac_deger=[1:15:91]
for min_value=[0.05 : 0.10: 0.45 ]
for kanal_indis=kanallar
%algorithm
end
end
end
end
end
end
a sample output:
22000 -> subject [ 1]: 1 2 4 1 2 0.01 31 0.25 --45.00 -0.15
22001 -> subject [ 1]: 1 2 5 1 2 0.01 31 0.25 --65.00 0.26
22002 -> subject [ 1]: 1 2 6 1 2 0.01 31 0.25 --55.00 0.06
22003 -> subject [ 1]: 1 2 7 1 2 0.01 31 0.25 --60.00 0.12
22004 -> subject [ 1]: 1 2 8 1 2 0.01 31 0.25 --45.00 -0.17
22005 -> subject [ 1]: 1 2 9 1 2 0.01 31 0.25 --40.00 -0.29
22006 -> subject [ 1]: 1 2 10 1 2 0.01 31 0.25 --55.00 0.02
22007 -> subject [ 1]: 1 2 11 1 2 0.01 31 0.25 --50.00 -0.08
22008 -> subject [ 1]: 1 2 12 1 2 0.01 31 0.25 --60.00 0.14
22009 -> subject [ 1]: 1 2 13 1 2 0.01 31 0.25 --45.00 -0.17

回答(1 个)

Ameer Hamza
Ameer Hamza 2020-10-15
Not using clc does not slow down your code. The display in command does not have a direct relation with the execution speed of your code. At least not enough to have a significant impact on your execution speed. One of the main reasons why execution speed becomes significantly slower is if you are expanding your arrays dynamically. Are you pre-allocating your arrays?
  2 个评论
Çağatay Murat Yılmaz
Dear Hamza, thank you very much for your answer. As you mentioned, it does not have a direct relation with printing values in command line. I had stored the paramater values in a dynamical "validasyon_sonuc" value. I have understand that it grows continuosly and creates a performance issue. I have pre-allocated my matrices and stored them on hard drive for futuru uses and the problem have solved.
validasyon_sonuc=[validasyon_sonuc; kanal_indis mi gi peak_threshold en_buyuk_kac_deger min_value acc kk];

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by