Parallel nested for loops variable classification error

3 ビュー (過去 30 日間)
Dean Morris
Dean Morris 2021 年 5 月 21 日
回答済み: Hrishikesh Borate 2021 年 5 月 24 日
if true
% code
parfor throw_1 = 1:1:6
for throw_2 = 1:1:6
RollTotal = throw_1 + throw_2;
NumbersThrownCount(RollTotal) = NumbersThrownCount(RollTotal) + 1;
end
end
end
I am having problems with this code, I am trying to use a parfor but I am getting a variable classification error any help on how to fix this would be amazing.

回答 (1 件)

Hrishikesh Borate
Hrishikesh Borate 2021 年 5 月 24 日
Hi,
It’s my understanding that you are trying to use the parfor loop and trying to avoid the variable classification error. Following is the code for the same:-
NumbersThrownCount = zeros(12,1);
if true
% code
for throw_2 = 1:1:6
temp = zeros(6,1);
parfor throw_1 = 1:1:6
RollTotal = throw_1 + throw_2;
temp(throw_1) = RollTotal;
end
NumbersThrownCount(temp) = NumbersThrownCount(temp) + 1;
end
end
For more information refer to Troubleshoot Variables in parfor-Loop.

カテゴリ

Help Center および 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