Convert Composite to array?

조회 수: 5 (최근 30일)
Erik S.
Erik S. 2015년 3월 28일
댓글: Walter Roberson 2020년 12월 1일
Is it possible to convert a Composite object created with spmd to an array?

채택된 답변

Edric Ellis
Edric Ellis 2015년 3월 30일
Yes, you can use Composite indexing (which behaves pretty much like cell array indexing), like this:
spmd
x = labindex;
end
xlocal = [x{:}]
  댓글 수: 2
Ronald Henry
Ronald Henry 2020년 12월 1일
is there a faster way? this method is sloooooow.
Walter Roberson
Walter Roberson 2020년 12월 1일
is there a faster way?
If I read the code correctly, you could use struct() to access private properties of the composite object, and then call some internal routines directly. It would take you a bit of research to figure out which routines to call on which objects, and you might have to shadow the existing class definitions to get access permissions to access the functions.
If I read the code correctly, if you did all of this, then for each composite member access, you would be able to skip one check of whether you are inside a parfor loop. Should be good for about 3 milliseconds per pool member.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by