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 Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by