Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Problem indexing in parfor

5 visualizaciones (últimos 30 días)
Juan Young
Juan Young el 6 de Nov. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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?

Respuestas (1)

Walter Roberson
Walter Roberson el 7 de Nov. de 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;

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by