Incompatible indexing of variable for parfor

I have a variable Network which is a cell array of size 5x12. Each cell is 76x1 double. Inside the parfor loop, in every iteration I need to use portions of the variable of size 5x3. This gives me a warning in the parfor that the variable is indexed in a way incompatible for the loop.
Here is a glimpse of my code. Can anybody suggest ways to modify the variable so that it can be made compatible with parfor loop
parfor j=1:4
sample=Network(:,(2*j)+(j-2):((2*j)+j);
........
end

5 件のコメント

Bruno Luong
Bruno Luong 2022 年 9 月 26 日
You column index ara overlapped grouped by 4 from 1 to 13, so I can't see where 5x3 come from
for j=1:4
(2*j)+(j-2):((2*j)+(j-1))+2
end
ans = 1×4
1 2 3 4
ans = 1×4
4 5 6 7
ans = 1×4
7 8 9 10
ans = 1×4
10 11 12 13
Hari
Hari 2022 年 9 月 27 日
My mistake, it is
parfor j=1:4
sample=Network(:,(2*j)+(j-2):((2*j)+j)
........
end
Walter Roberson
Walter Roberson 2022 年 9 月 27 日
overlapping reference to a variable is not permitted.
Hari
Hari 2022 年 9 月 27 日
The result for the code is here. I am not sure what overlapping refers to, but I think there is no overlap here. Correct me if I am wrong
for j=1:4
(2*j)+(j-2):((2*j)+j)
end
ans = 1×3
1 2 3
ans = 1×3
4 5 6
ans = 1×3
7 8 9
ans = 1×3
10 11 12
Bruno Luong
Bruno Luong 2022 年 9 月 27 日
Then reshape your array in 3D
Networkr = reshape(Network, size(Nerworks,1), 3, []);
then use parforloop on the third dimension.

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

回答 (1 件)

Edric Ellis
Edric Ellis 2022 年 9 月 27 日

0 投票

The total size in bytes of Network is 5*12*76*8 = 36480. That is tiny. Ignore the parfor "broadcast" warning - that is intended to alert you when you might accidentally be sending gigabytes to each worker. It is irrelevant in this case.

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2022 年 9 月 26 日

回答済み:

2022 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by