Run parallel function.

조회 수: 12 (최근 30일)
NGOC TAM LAM
NGOC TAM LAM 2019년 10월 3일
답변: Hari Krishna Ravuri 2019년 12월 5일
HI all,
I have one function with different input values
function chooseDirectionRolling(Coord,Arrow)
for i=1:100
doRolling(Coord,Arrow); %an example of other function
Coord=Coord+i;
end
end
I want to run this function for four direction at the same time, when I do as below, it takes times
chooseDirectionRolling(rightCoord,rightArrow);
chooseDirectionRolling(leftCoord,leftArrow);
chooseDirectionRolling(upCoord,upArrow);
chooseDirectionRolling(downCoord,downArrow);
Q: How can I run at the same time for one function with different input variables?
I tried to used parfor but it did not work.

답변 (1개)

Hari Krishna Ravuri
Hari Krishna Ravuri 2019년 12월 5일
I understand that, you want to execute four functions parallely.You may consider using parfeval.The syntax of parfeval is
F = parfeval(p,fcn,numout,in1,in2,)

카테고리

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