valid indices for 'output' are restricted in parfor loop

3 ビュー (過去 30 日間)
soepblik
soepblik 2021 年 3 月 3 日
編集済み: soepblik 2021 年 3 月 3 日
Hi,
i have the following code:
for j= 1:100
SNR = list(j);
parfor i = 1:1000
tot = (j-1)*1000+i;
totallist(tot,1) = SNR;
output(tot,1) = awgn(input(tot,1),SNR);
end
end
tot is just the total counter of the full loop
so the full loop contains 100*1000 values.
But why is the output(tot,1) and totallist(tot,1) forbidden?
How can i do it on another way?

採用された回答

Walter Roberson
Walter Roberson 2021 年 3 月 3 日
for j= 1:100
SNR = list(j);
base = (j-1)*1000;
parfor i = 1:1000
totallist(base+i,1) = SNR;
output(base+i,1) = awgn(input(base+i,1),SNR);
end
end
"Form of Indexing. Within the first-level of indexing for a sliced variable, exactly one indexing expression is of the form i, i+k, i-k, or k+i. The index i is the loop variable and k is a scalar integer constant or a simple (non-indexed) broadcast variable. Every other indexing expression is a positive integer constant, a simple (non-indexed) broadcast variable, a nested for-loop index variable, colon, or end."
  1 件のコメント
soepblik
soepblik 2021 年 3 月 3 日
編集済み: soepblik 2021 年 3 月 3 日
ahh thanks for the clear explanation! It is working now

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by