Alternative method needed for a few 'for' loops inside each other
1 view (last 30 days)
Show older comments
Hi,
I have 4 for loops inside each other as seen here:
for A=1:a
for B=1:b
for C=1:c
for D=1:d
do_something (A,B,C,D)
end
end
end
end
The values of A, B, C, D are dependent on each other so I can't calculate them separately. The issue is that this is extremely slow. Could anyone please help me with an alternative fast method? Thank you very much for your time and help.
0 Comments
Answers (1)
Jan
on 8 Mar 2015
No. It is impossible to give a useful suggestion based on this abstract code. The problem is not the nested loops, but the code hidden behind "do_something". The explanation "A, B, C, D are dependent" does not allow to understand the underlying concept.
The profiler helps to identify teh bottlenecks of the program. Use it and post the corresponding code in a less simplified manner. Then a helpful suggestion is possible.
4 Comments
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!