필터 지우기
필터 지우기

for loop inside parfor loop

조회 수: 1 (최근 30일)
Karthik
Karthik 2015년 1월 13일
편집: Matt J 2015년 1월 13일
Hello, i am getting the following error for this loop.
Error using In (line 78) Error: The variable f in a parfor cannot be classified. See Parallel for Loops in MATLAB, "Overview".
parfor j = 1:size(lam,2);
c(:,j) = fminunc(@(c) (chi1(c, K0_com)), cint, options);
for i = 1:Steps*Steps
f(i,j) = K0_com(:,i)'*c(:,j);
f(i,j) = (f(i,j)>0)*f(i,j);
end
end
How can I fix this? I did not see any warning or error when I wrote this.

채택된 답변

Matt J
Matt J 2015년 1월 13일
편집: Matt J 2015년 1월 13일
I would take the processing of f out of the loop altogether. Just post-compute it using vectorized methods:
parfor j = 1:size(lam,2);
c(:,j) = fminunc(@(c) (chi1(c, K0_com)), cint, options);
end
f=K0_com.'*c;
f=f.*(f>0);

추가 답변 (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