Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problem indexing in parfor

조회 수: 5 (최근 30일)
Juan Young
Juan Young 2016년 11월 6일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello, I have a program (an Ising model) which I must make it evolve until certain state, and then start to save the data in an array. But as im using parfor, I cant use the normal way of indexing. The code is something like this:
parfor T=1:nT
for i=1:tfinal
f=Function(f,parameters);
if i> (tfinal-tdat)
j=j+1 <--------------------------------Here is the problem
MdeT(T,j)=sum(sum(L));
EdeT(T,j)=E;
end
end
end
Thats how I want it to work, but I CANT use the "j" cumulative parameter inside the "MdeT", array in which I want to gather the information. How can I possibly do to save the information past a certain point, and not since the beginning, in a parfor?

답변 (1개)

Walter Roberson
Walter Roberson 2016년 11월 7일
You cannot.
However, you can save to cell arrays or structs with consistent indexing and with empty contents. Or you could,
MdeT(T, j - (tfinal - tdat)) = sum(sum(L));
EdeT(T, j - (tfinal - tdat)) = E;

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by