필터 지우기
필터 지우기

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