Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Problem indexing in parfor

3 Ansichten (letzte 30 Tage)
Juan Young
Juan Young am 6 Nov. 2016
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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?

Antworten (1)

Walter Roberson
Walter Roberson am 7 Nov. 2016
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;

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by