フィルターのクリア

function status in parfeval / fetchOutputs

2 ビュー (過去 30 日間)
Alexander Braun
Alexander Braun 2015 年 1 月 26 日
回答済み: Alexander Braun 2015 年 1 月 27 日
Hello everybody,
I am planning a script which runs 2 functions simultaneously in a loop, using parfeval and fetchOutputs. These 2 functions will have different evaluation times like 2E-3s and 0.04s. If I am using fetchOutputs ,my loop will wait for the slower function to finish what is not desired. Therefore, I would like to ask if there is any way to check the status of my slower function i.e. using fetchOutputs only if the function is finished and keep the faster function running in the loop.
Cheers
Alexander Braun

採用された回答

Edric Ellis
Edric Ellis 2015 年 1 月 27 日
You can check the State property of the Future object returned by parfeval to see if it has finished. You might also be able to use the fetchNext method with a timeout of 0 to collect the result if it's ready. Something like this (untested...)
while keepGoing
fslow = parfeval(@slowFcn, ...);
while isempty(fetchNext(fslow, 0))
% fetchNext returns empty if it hits the timeout.
fquick = parfeval(@quickFcn, ...);
quickResult = fetchOutputs(fquick);
end
slowResult = fetchOutputs(fslow);
end

その他の回答 (1 件)

Alexander Braun
Alexander Braun 2015 年 1 月 27 日
Looks promising. Thanks a lot.

カテゴリ

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