Increase SPEED of nested for loops???

4 ビュー (過去 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 Center および File ExchangeFunction Creation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by