Increase SPEED of nested for loops???

조회 수: 2 (최근 30일)
Francesco Porretta
Francesco Porretta 2021년 11월 4일
답변: Jan 2021년 11월 4일
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!

채택된 답변

Jan
Jan 2021년 11월 4일
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개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by