How to fix indexing?
Mostrar comentarios más antiguos
Hi! I am trying to run a parfor loop on matlab, but the parfor doesn't want to run because the indexing of a variable is not working out.
Here is the code
parfor ii = 1:1:2*nsim
%p is a temporary variable
p = pvals(2);
if ii> nsim
p = pvals(2);
kk = k(ii-nsim);
else
kk = k(end);
end
disp(ii)
[MuTmpA,MuTmpB,VarTmpA,VarTmpB,CovTmpAB,Scatter_tmp]
= ModelCalc(kk,s_1,s_2,N,T,q,p,f,n_plt,pop_sample, plt_step);
MuA(:,ii) =
MuTmpA;
MuB(:,ii) = MuTmpB;
VarA(:,ii) = VarTmpA;
VarB(:,ii)
= VarTmpB;
CovAB(:,ii) = CovTmpAB;
*Scatter_final(:,2*ii-1:2*ii)=
Scatter_tmp* ;
end
The issue is with the Scatter_final variable the asterik line. The following message appears:
Explanation For MATLAB to execute parfor loops efficiently, the amount of data sent to the MATLAB workers must be minimal. One of the ways MATLAB achieves this is by restricting the way variables can be indexed in parfor iterations. The indicated variable is indexed in a way that is incompatible with parfor.
Suggested Action Fix the indexing. For a description of the indexing restrictions, see “Sliced Variables†in the Parallel Computing Toolbox documentation.
Thanks so much for reading my question!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Parallel for-Loops (parfor) en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!