Variable in parfor cannot be classified
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I've looked for answers on this forum but each situation seems to different from mine. My code sends some data to a function which outputs many variables which are defined as sets of tau coefficients (or a tau by tau matrix) on a Nx by Ny mesh.
Here is my code:
speedmaxF = 0;
system_cell = NaN(tau,Nx,Ny);
trunc_east = NaN(tau,Nx,Ny);
trunc_west = NaN(tau,Nx,Ny);
Jac_trunc_east = NaN(tau,tau,Nx,Ny);
Jac_trunc_west = NaN(tau,tau,Nx,Ny);
Jac_cell = NaN(tau,tau,Nx,Ny);
Jac_east_cell = NaN(tau,tau,Nx,Ny);
Jac_west_cell = NaN(tau,tau,Nx,Ny);
Jac_east_other = NaN(tau,tau,Nx,Ny);
Jac_west_other = NaN(tau,tau,Nx,Ny);
flux_east = NaN(tau,Nx,Ny);
flux_west = NaN(tau,Nx,Ny);
DGprev_ghosts_east = NaN(tau,Nx,Ny);
DGprev_ghosts_west = NaN(tau,Nx,Ny);
DGprev_ghosts_east(:,1:(end-1),:,:) = DGprev_ghosts(:,2:end,:,:);
DGprev_ghosts_west(:,2:end,:,:) = DGprev_ghosts(:,1:(end-1),:,:);
parfor index1 = 1:Nx
for index2 = 1:Ny
qstar = DGprev_ghosts(:,index1,index2);
qeast = DGprev_ghosts_east(:,index1,index2);
qwest = DGprev_ghosts_west(:,index1,index2);
v1center = v1centers(index1);
v2center = v2centers(index2);
cellcenter = [v1center v2center];
[trunc_east(:,index1,index2),trunc_west(:,index1,index2), ...
flux_east(:,index1,index2), flux_west(:,index1,index2), ...
Jac_east_cell(:,:,index1,index2),Jac_west_cell(:,:,index1,index2), ...
Jac_east_other(:,:,index1,index2),Jac_west_other(:,:,index1,index2), ...
Jac_trunc_east(:,:,index1,index2),Jac_trunc_west(:,:,index1,index2), ...
Jac_cell(:,:,index1,index2),system_cell(:,index1,index2),maxspeedF] ...
= predictor_precompute_eastwest(qstar,qeast,qwest,qstar,data,cellcenter);
speedmaxF(iv1ghost) = max([speedmaxF(iv1ghost) maxspeedF]);
end
end
The error message is:
Error: File: predictor_main.m Line: 146 Column: 10
The variable trunceast in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".
I have tried by adding things like truncteast = trunceast after the loop, but nothing seems to work. Suggestions?
3 commentaires
Walter Roberson
le 18 Fév 2016
Yes, that is an appropriate approach: write into a temporary vector in the inner loop, and assign the vector as a whole to the appropriate output space in the outer loop.
Réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!