Trying too run two functions in parallel where the functions have two outputs

조회 수: 2 (최근 30일)
So I have two functions which I want to run in parallel and I want to store the two output values of each function in a cell. The problem I'm having is it only seems to be storing one of the outputs of each function and I dont know why.
funcs1 = {@linear_programming_bound, @linear_programming_bound};
arguments1 = {W,b,Xmins(:,j),Xmaxes(:,j);
W,b,Xmins(:,z),Xmaxes(:,z)};
solutions1 = cell(1,2);
M = 4;
parfor (ii = 1:2,M)
solutions1{ii}=funcs1{ii}(arguments1{ii,:});
end
M = solutions1{1}; N = solutions1{2};
P.S. Sorry, I know this same peice of code has been used in a fair few questions here.

채택된 답변

Walter Roberson
Walter Roberson 2020년 1월 18일
funcs1 = {@linear_programming_bound, @linear_programming_bound};
arguments1 = {W,b,Xmins(:,j),Xmaxes(:,j);
W,b,Xmins(:,z),Xmaxes(:,z)};
solutions1 = cell(1,2);
solutions2 = cell(1,2);
M = 4;
parfor (ii = 1:2,M)
[solutions1{ii}, solutions2{ii}] = funcs1{ii}(arguments1{ii,:});
end
M = solutions1{1}; N = solutions1{2};

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by