can anyone will explain the syntax of F = parfeval(p,fcn,numout,in1,in2,...) this? p(builds parallel pool),fcn(is the function),What is numout,in1,in2? I have 3output from the function how can i use that output using fetchoutputs(f)? Kindly give answers.

 채택된 답변

Walter Roberson
Walter Roberson 2018년 2월 15일

0 개 추천

You need to have an existing parpool stored in a variable that you pass in as the first parameter.
fun is the handle of the function to be executed.
If you need the third output then numout should be at least 3: the value should be the maximum number of output that you need from each call.
When you collect the output then you will get a cell array if I recall correctly, which you can index at {3}

댓글 수: 3

DhanaLakshmiR
DhanaLakshmiR 2018년 2월 23일
편집: Walter Roberson 2018년 2월 23일
I don't know that i have used the syntax correctly. Help me with correct syntax.
function [xposition yposition altitude]=sixdof(xpos,ypos,alt)
xpos=xpos+velx*delt;
ypos=ypos+vely*delt;
alt=alt-velz*delt;
end
Im having the above code in separate mfile. I need this value simultaneously in another mfile so i have included parfeval. But i dont know about that concept.
p = gcp();
value=0;
while(1)
Moving(value);
Default syntax is f=parfeval(p,@func,numout,in1,in2..)
so that i have used like this f = parfeval(p, @sixdof,3,1,2,3)
value = fetchOutputs(f)
end
In sixdof function i have 3outputs by using the above code can i get that value from sixdof function?
function[position values]= Moving(value)
{
body
}
I want to fetch the output from the first mfile and have to be used in the above code can i? Kindly explain.
Walter Roberson
Walter Roberson 2018년 2월 23일
Yes, that should work.
However, remember that there is overhead is communicating with a parallel pool and asking it to do work and getting the results back, so using parfeval is slower if the work to be done is not "big enough" or if you do not have at least two workers processing data. In the code outline you show, you are always immediately waiting for the future you just created, so you will only ever have one future executing at a time, and the amount of work you are asking the future to do is trivial so the cost of using the parfeval will overwhelm any benefits. In the code you outline, you would be better off just calling sixdof directly without any parallel pool.
DhanaLakshmiR
DhanaLakshmiR 2018년 2월 24일
Thank you for your explanation.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Background Processing에 대해 자세히 알아보기

태그

질문:

2018년 2월 15일

댓글:

2018년 2월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by