How to fix my code with parfor-Loops array?

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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2019b

질문:

2020년 6월 5일

답변:

2020년 6월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by