Effacer les filtres
Effacer les filtres

Understanding nested function reference in parfor loop

1 vue (au cours des 30 derniers jours)
Supreeth
Supreeth le 18 Mar 2015
Commenté : Jonathan Chin le 19 Oct 2017
I came accross this sentence in MATLAB doc:
The body of a parfor-loop cannot make reference to a nested function. However, it can call a nested function by means of a function handle.
Can someone please explain what this means?
  2 commentaires
Jason Stockton
Jason Stockton le 19 Oct 2017
Yes, Please. I am having an issue with it now. Thanks.
Jonathan Chin
Jonathan Chin le 19 Oct 2017
Look at this examples where I am creating a function handle for my nested function.
function out=parforTest(in)
out = zeros(1,4);
tmp=@(x)nestedFunc(in,x);
parfor ii=1:4
out(ii)=feval(tmp,ii)
end
function outv= nestedFunc(in,var)
outv = in+var;
end
end

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Parallel for-Loops (parfor) 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!

Translated by