How to fix my code with parfor-Loops array?

1 回表示 (過去 30 日間)
PRED LIU
PRED LIU 2020 年 6 月 5 日
回答済み: Edric Ellis 2020 年 6 月 5 日
My code have a lot of error ,how to fix ?
X = ones( 1 ,3);
B = zeros( 20 ,3);
parfor i = 1 : 6
kIndex = 1+2*(i-1) : 2*i;
B(kIndex,:) = X;
end

採用された回答

Edric Ellis
Edric Ellis 2020 年 6 月 5 日
Output variables in parfor must be either sliced or reduction. There's more information in the doc. But basically, you cannot assign into an output variable like B using a computed index in the way that you are doing. One of the subscripts into B must be the loop index i.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by