Dot indexing is not supported for variables of this type??? Parfor loop, and global variable

32 ビュー (過去 30 日間)
Yi Xien Yap
Yi Xien Yap 2022 年 8 月 5 日
コメント済み: Yi Xien Yap 2022 年 8 月 10 日
I'm trying to run a parfor loop for my simulation. But I got an error "Dot indexing is not supported for variables of this type", beside on this line, I still got the similar error and I couldn't figure out what went wrong. In the test_simdata function, there is a global variable and I'm bypassing it using a function, not sure if this is the cause.
%Main Function
clear
clc
iCellNum = 1;
activeUeNums = 1;
parfor ttiNum = 1 : 20
timeDomainSignal{ttiNum} = test3(iCellNum, ttiNum, activeUeNums);
end
%test3
function test = test3(iCellNum, iTtiNum, iActiveUeList)
g = test_global;
simData = test_simData;
substr.simData = struct();
substr.simData.outputFolder = g.G_SIMULATION_OUTPUT_PATH;
substr.simData.cellId = simData.cell(iCellNum).cellId;
substr.simData.chanBW = simData.cell(iCellNum).bw;
substr.simData.simLen = simData.cell(iCellNum).totalSf;
substr.simData.txAnt = simData.cell(iCellNum).txAnt;
substr.simData.pairedSpectrum = simData.cell(iCellNum).pairedSpectrum;
substr.simData.ssBlockNumerology = simData.cell(iCellNum).ssBlockNumerology;
numerologyIndex = substr.simData.ssBlockNumerology + g.G_MATLAB_START_INDEX_OFFSET;
substr.simData.ssNumerologyOneOpt = simData.cell(iCellNum).ssNumerologyOneOpt;
substr.simData.subCarrierSpace = getSubCarrierSpace(simData.LuT, substr.simData.ssBlockNumerology);
substr.simData.gridConfig = simData.cell(iCellNum).grid;
substr.simData.gridOffsetForNumerology = substr.simData.gridConfig(numerologyIndex).offsetNsc;
end
%test_simData
function y = test_simData
global simData
y = simData;
end

回答 (2 件)

Walter Roberson
Walter Roberson 2022 年 8 月 6 日
You can use parallel.pool.Constant to send a copy of the data to all workers, and you can use parfevalOnAll to run a function on the workers to copy the constant into the (per-worker) global variable.
  10 件のコメント
Yi Xien Yap
Yi Xien Yap 2022 年 8 月 8 日
Thanks guys, I think I know where the problem is
Walter Roberson
Walter Roberson 2022 年 8 月 8 日
parfevalOnAll(@() store_simData(simdata_constant), 0);

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


Bruno Luong
Bruno Luong 2022 年 8 月 5 日
The global variable is not accessible by the workers, and it will return EMPTY when you are trying tp access to it. Soo if you assume it's a structure, your code will crash.
  7 件のコメント
Bruno Luong
Bruno Luong 2022 年 8 月 8 日
"After I have the simData initialize"
But I think the probleme is it is NOT initialize. That is why the value is an empty array and not a struct.

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

カテゴリ

Help Center および File ExchangeScan Parameter Ranges についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by