Increase SPEED of nested for loops???

2 Ansichten (letzte 30 Tage)
Francesco Porretta
Francesco Porretta am 4 Nov. 2021
Beantwortet: Jan am 4 Nov. 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!

Akzeptierte Antwort

Jan
Jan am 4 Nov. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by