Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

is there to make this double room to run faster?

1 visualización (últimos 30 días)
jenka
jenka el 20 de Sept. de 2012
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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

Respuestas (1)

Walter Roberson
Walter Roberson el 20 de Sept. de 2012
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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by