Question: I think that the variable A below is a sliced variable but I am unsure how I am violating parfor restrictions - is there any way I can parallelize this?
I receive the error: `Error: The variable A in a parfor cannot be classified.' when I run the following:
parfor j = 1:J
for t = 1:T
A(t+1,j) = interp1(x,V(:,b(t),j),A(t,j),'linear');
end
end
A minimum working example setup just before I invoke the parfor command is:
J = 5;
T = 310000;
A = zeros(310001,5); A(1,:) = ones(1,5);
x = (0.01:0.01:10);
V = repmat(x',[1 3 5]); % V is 1000x3x5
rng('default');
b = randi([1 3],310001,1);

 채택된 답변

Walter Roberson
Walter Roberson 2017년 4월 7일

1 개 추천

Use the general structure
parfor j=1:J
tA = zeros(T+1,1);
tA(1) = A(1,j);
for t = 1:T
tA(t+1) =..... tA(t)...
end
A(:, j) = tA;
end

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

태그

질문:

2017년 4월 7일

댓글:

2017년 4월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by