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

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

Walter Roberson
Walter Roberson le 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};

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by