I have a big 3d matrix of size (2000,700,300) for which I want to run a nested for loop on .
the loop will be spatially only, meaning i goes 1:2000 and j 1:700 , pixel by pixel.
the thing is , it takes a very very long time.
is there a way to speed this up? I have tried parfor but it only makes it slower ...
i have a strong gpu if that helps.
also , I thought of using functions like nlfilter or blockproc , but they only take a picture of 1 or 3 dimensions as an argument.
7 Comments
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663311
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663311
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663324
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663324
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663326
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663326
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663339
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663339
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663389
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663389
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663390
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663390
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663491
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/441033-how-to-run-nested-for-loop-efficiently-on-3d-matrix#comment_663491
Sign in to comment.