필터 지우기
필터 지우기

Understanding nested function reference in parfor loop

조회 수: 1 (최근 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 CenterFile Exchange에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by