Classification of variables in parfor-Loop
Afficher commentaires plus anciens
Good day,
I am reaching out because I have some problems with the Classification of variables in parfor-Loop.
I have declared the variable V outside the parfor-Loop in order to make it a Sliced output Variable, but a warning comes up saying: "The parfor-Loop cannot run due to the way variable, 'V' is used".
I have tried to declare V (line 1), inside the parfor-Loop and it works, but then is a temporal variable and I can not use it after the parfor-Loop.
Could you please help me to define V as a Sliced output Variable? V is the variable that I have to work with after the parfor-Loop.
Thanks in advance.
1 V=zeros(numel(Ppara),numel(Pperp),numel(tau));%
2
3 parfor j_G=1:numel(Ppara)*numel(Pperp)
4 % rest of the code
5
6 V(JG(j_G,1),JG(j_G,2),: )=sum(Ap_tau);
7 end
The matrix JG is:
JG =
1 1
1 2
2 1
2 2
3 1
3 2
4 1
4 2
Réponses (1)
N=numel(Pperp); M=numel(Ppara);
V=zeros(N*M,numel(tau));%
parfor j_G=1:N*M
%rest of code
V(j_G, : )=sum(Ap_tau);
end
V=permute( reshape(V,N,M,[]) ,[2,1,3]);
2 commentaires
Rodrigo Sierra
le 10 Avr 2022
Matt J
le 10 Avr 2022
You're probably running your old script by mistake. There's no way it's the same.
Catégories
En savoir plus sur Parallel for-Loops (parfor) dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!