Dot indexing is not supported for variables of this type??? Parfor loop, and global variable
33 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Walter Roberson
le 6 Août 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 commentaires
Walter Roberson
le 8 Août 2022
parfevalOnAll(@() store_simData(simdata_constant), 0);
Bruno Luong
le 5 Août 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 commentaires
Bruno Luong
le 8 Août 2022
"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.
Voir également
Catégories
En savoir plus sur Scan Parameter Ranges dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!