Multiple outputs with parfeval

17 ビュー (過去 30 日間)
Carlos Valle Araya
Carlos Valle Araya 2019 年 10 月 26 日
回答済み: Edric Ellis 2019 年 10 月 28 日
Hi! I'm trying to obtain multiple outputs of parfeval but i get an error about many output arguments.
noutputs = 2;
[a,b]= parfeval(@SUMA,noutputs,3)
A = fetchOutputs(a)
B = fetchOutputs(a)
function [y1, y2] = SUMA(n)
y1 = n;
y2 = n+1;
end
Thanks !!

回答 (1 件)

Edric Ellis
Edric Ellis 2019 年 10 月 28 日
Each call to parfeval always returns only a single Future object. You can then subsequently request multiple outputs when you call either fetchOutputs or fetchNext, like this:
% Start a simple function request, asking for 2 outputs
f1 = parfeval(@deal, 2, magic(2), rand(2));
% Retrieve the outputs using fetchOutputs
[magic2, rand2] = fetchOutputs(f1)
% Or, using fetchNext
f2 = parfeval(@deal, 2, magic(3), rand(3));
[idx, magic3, rand3] = fetchNext(f2) % 'idx' is always 1 in this case.
(If you're not familiar with it - the function deal simply returns its inputs as outputs)

カテゴリ

Help Center および File ExchangeBackground Processing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by