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

14 views (last 30 days)
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

Answers (2)

Walter Roberson
Walter Roberson on 6 Aug 2022
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 Comments

Sign in to comment.


Bruno Luong
Bruno Luong on 5 Aug 2022
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 Comments

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!