Increase SPEED of nested for loops???
1 view (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Jan
on 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.
0 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!