Variable in parfor cannot be classified

5 Ansichten (letzte 30 Tage)
Pierson
Pierson am 18 Feb. 2016
Kommentiert: Pierson am 22 Feb. 2016
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 Kommentare
Walter Roberson
Walter Roberson am 18 Feb. 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.
Pierson
Pierson am 22 Feb. 2016
Thanks! Very helpful. Any ideas on how to make sure that the speedup in this code is optimal?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by