How can i save the temporary variable inside the parfor loop for the below code ? i have also tried using SPMD but it takes more time that the normal problem running in one core takes and how will i be able to find the thread number of each worker ?
조회 수: 4 (최근 30일)
이전 댓글 표시
i wanted to save the temp variable 'temp' and i cant find any way to do it..i would appreciate any help thank you
C is 300x52 matrix,D is 6x300 matrix, k is a 6x300 matrix,N is 50 and offs is 3,
parfor n=1:6
temp=[];
A=zeros(300,(N+offs) +N);
for m=1:N+offs
A(1:300,m)=k.*C(1:300,m);
end
inda=N+offs;
for m=1:N
A(1:300,inda+m)=-k.*C(1:300,m).*D(n,1:300).';
end
temp=A\B;
end %for n=1:Nc
댓글 수: 0
답변 (1개)
Namnendra
2022년 6월 19일
As seen in the code, you have 6 instances of temp to be saved. You can create a structure which is outside the parfor loop and assign its size to be n(=6). So you can assign that particular temp at the corresponding index of n in the structure. You can later retrieve the value of temp from the structure.
I hope it helps.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!