How to fix my code with parfor-Loops array?

1 Ansicht (letzte 30 Tage)
PRED LIU
PRED LIU am 5 Jun. 2020
Beantwortet: Edric Ellis am 5 Jun. 2020
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

Akzeptierte Antwort

Edric Ellis
Edric Ellis am 5 Jun. 2020
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.

Weitere Antworten (0)

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by