Variable in parfor cannot be classified

조회 수: 5 (최근 30일)
Pierson
Pierson 2016년 2월 18일
댓글: Pierson 2016년 2월 22일
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
Walter Roberson
Walter Roberson 2016년 2월 18일
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 2016년 2월 22일
Thanks! Very helpful. Any ideas on how to make sure that the speedup in this code is optimal?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by