フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

is there to make this double room to run faster?

1 回表示 (過去 30 日間)
jenka
jenka 2012 年 9 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi guys, I am trying to reduce the cost of running my program: is there a way to reduce two pieces of code: FIRST ONE:
for i=1:sz(2)
for j=1:sz(3)
rms_NTG10(ls,i,j) = sqrt(mean(err_NTG10(:,i,j).^2));
rms_NTG20(ls,i,j) = sqrt(mean(err_NTG20(:,i,j).^2));
rms_NTG30(ls,i,j) = sqrt(mean(err_NTG30(:,i,j).^2));
rms_NTG40(ls,i,j) = sqrt(mean(err_NTG40(:,i,j).^2));
rms_NTG50(ls,i,j) = sqrt(mean(err_NTG50(:,i,j).^2));
rms_NTG60(ls,i,j) = sqrt(mean(err_NTG60(:,i,j).^2));
rms_NTG70(ls,i,j) = sqrt(mean(err_NTG70(:,i,j).^2));
rms_NTG80(ls,i,j) = sqrt(mean(err_NTG80(:,i,j).^2));
rms_NTG90(ls,i,j) = sqrt(mean(err_NTG90(:,i,j).^2));
rms_NTG100(ls,i,j) = sqrt(mean(err_NTG100(:,i,j).^2));
end
end
SECOND ONE:
for i=1:sz(2)
for j=1:sz(3)
accum_ar(i,j,accum_index(i,j)) = accum_ar(i,j,accum_index(i,j)) + 1;
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2012 年 9 月 20 日
In the first situation, you can run the sqrt() after the rest of the calculations, such as
rms_NTG10(ls,:,:) = sqrt(rms_NTG10(ls,:,:));
Also, you can square the errors before you start:
err_sq_NTG10 = err_NTG10.^2;
and then pull out the part of that you need for each mean ()
Reducing the number of calls to identical operations is usually faster.

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by