Increase SPEED of nested for loops???

2 visualizaciones (últimos 30 días)
Francesco Porretta
Francesco Porretta el 4 de Nov. de 2021
Respondida: Jan el 4 de Nov. de 2021
This is my code, which use 6 for loops for generating a 6D array, where the data are taken using a neural network:
T = ones(g.size); %6D array
for ii = 1 : g.N(1) % 4
for jj = 1 : g.N(2) % 10
for tt = 1 : g.N(3) % 5
for pp = 1 :g.N(4) % 4
for rr = 1 : g.N(5) % 6
for ss = 1 : g.N(6) % 2
T(ii,jj,tt,pp,rr,ss) = sim(net,[g.data{1, 1}(ii);...
g.data{2, 1}(jj);...
g.data{3, 1}(tt);...
g.data{4, 1}(pp);...
g.data{5, 1}(rr);...
g.data{6, 1}(ss);...
1;
1;]);
end
end
end
end
end
end
There exist a way to reduce these for loops for reducing computational time?
Thanks in advance!

Respuesta aceptada

Jan
Jan el 4 de Nov. de 2021
Use the profiler to find out, where the time is spent. If it is inside the sim() command, you have to modify this block, because the for loops arenot the problem.

Más respuestas (0)

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by