Understanding nested function reference in parfor loop

3 ビュー (過去 30 日間)
Supreeth
Supreeth 2015 年 3 月 18 日
コメント済み: Jonathan Chin 2017 年 10 月 19 日
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 件のコメント
Jason Stockton
Jason Stockton 2017 年 10 月 19 日
Yes, Please. I am having an issue with it now. Thanks.
Jonathan Chin
Jonathan Chin 2017 年 10 月 19 日
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

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by