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

1 件のコメント

Michael
Michael 2017 年 4 月 7 日
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeParallel for-Loops (parfor) についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by