Classification of variables in parfor-Loop

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)

Matt J
Matt J le 9 Avr 2022
Modifié(e) : Matt J le 9 Avr 2022
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

Hi @Matt J,
Thanks for helping me.
I have tried your solution, but the error remains, exactly as before.
I would appreciate if, based on your experience, you could help me with another suggestion.
Thanks again.
Matt J
Matt J le 10 Avr 2022
You're probably running your old script by mistake. There's no way it's the same.

Connectez-vous pour commenter.

Catégories

Produits

Version

R2019b

Tags

Commenté :

le 10 Avr 2022

Community Treasure Hunt

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

Start Hunting!

Translated by