Update each element of multi dimensional array

조회 수: 13 (최근 30일)
bilal javed
bilal javed 2019년 4월 4일
댓글: Walter Roberson 2019년 4월 18일
Hello!
i am working with multi dimensional arrays, and I need to check every combination of values and update them. For this pusrpose, I am using for loops but they are super slow. I have waited hours but it was still processing. Is there any faster way?
My code for 3D array is like this
for i = 1:nrows
for j = 1:ncols
for k = 1:ndepths
AI = function(a(i), b(j), c(k));
cspace (i,j,k) = JKM(AI);
end
end
end
  댓글 수: 18
Guillaume
Guillaume 2019년 4월 18일
The error message tells you the out of memory occurs in the parfor. So, it all depends on that GJK function for which you haven't shown the code.
What's the output of memory before you execute the parfor loop? By far, the biggest variable is your fv which uses ~4.5 GB of memory.
Walter Roberson
Walter Roberson 2019년 4월 18일
I just noticed that your fv is a struct with fields face and vertices. That suggests that you are creating four patch objects for each of your 296487 struct array elements, and that those form parameters to whatever GJK does. That is a lot of graphics objects, over 72 million verticles for the fv alone, and unknown numbers of graphics elements triggered by the obstacle patches.
Note that graphics objects created on parallel workers cannot change the display: parallel workers are different processes that work independently without connection to the graphics display thread.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by