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

2 views (last 30 days)
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.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Jan 2020
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};

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!