필터 지우기
필터 지우기

Problem using parfor: Variable cannot be classified

조회 수: 2 (최근 30일)
Guilherme Roberto
Guilherme Roberto 2016년 3월 16일
답변: Walter Roberson 2016년 3월 16일
Hi.
I'm using parfor to increase the performance in my program but I having some trouble in the following code:
function [p] = perc(img,maxr)
aux=double(img); %save image on an auxiliar matrix
r=3:2:maxr; %box sizes
p=zeros(r(1,length(r))^2,size(r,2)); %a column for each box size
parfor k=1:size(r,2)
ncaixas=(size(img,1)-r(k)+1)*(size(img,2)-r(k)+1);
lim=(r(k)/2)-0.5;
for x=lim+1:(size(img,1)-lim)
for y=lim+1:(size(img,2)-lim)
.
.
.
%ordinary instructions
.
.
.
if(condition)
ROT=ROT+1;
end
p(ROT,k)=p(ROT,k)+ROT;
end
end
p(:,k)=p(:,k)./ncaixas;
end
end
MATLAB says to me that I can't use parfor in this case due to the way the variable p is used.
Is there anything I can do to fix this?
Thank you.
BTW, I'm running R2015b

채택된 답변

Walter Roberson
Walter Roberson 2016년 3월 16일
You cannot assign to p(ROT,k) in a loop. You should assign to a temporary vector and then afterwards assign the temporary to p(:,k)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by