slicing flag with parfor, cannot identify error

MatLab flagged an error in my parfor loop. The error is roughly 'valid indices are restricted in parfor loops'. Have read the sliced variables documentation and cannot determine the problem. Similar code and my attempted diagnosis follow.
N=10;
M=20;
DTc = zeros(M,2,2);
DTcs1 = zeros(M,N);
DTcs2 = zeros(M,N);
parfor kIter = 1:M
DT = eye(2);
DTs = reshape(repmat(eye(2),[N,1]),[N,2,2]);
DTc(kIter,:,:) = DT; %flagged
DTcs1(kIter,:) = DTs(:,1,1); %flagged
DTcs2(kIter,:) = DTs(:,2,2); %flagged
end
I read the documentation and DTc, DTcs1 and DTcs2 seem to fit the four characteristics of sliced variables.

4 件のコメント

Huy Dinh
Huy Dinh 2020 年 1 月 3 日
Also posted this on stackoverflow.
Jeremy
Jeremy 2020 年 1 月 3 日
Your code runs for me with no errors. Do you have the parallel computing toolbox?
Huy Dinh
Huy Dinh 2020 年 1 月 3 日
I believe so. I have been able to run code with parfor loops. Not sure if parallel computing toolbox is required to run parfor loops.
Huy Dinh
Huy Dinh 2020 年 1 月 3 日
Just removed the flag by retyping the code. I'm confused.

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

回答 (0 件)

カテゴリ

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

質問済み:

2020 年 1 月 3 日

コメント済み:

2020 年 1 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by