Stop an infinit function that is running in parallel with the remaining code, and get the outputs
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I am looking for a way to retrieve the output of a function that is running in parallel (with the function parfeval for example) and that can run indefinitely if we don't stop it in the remaining code.
For example : This could be the function :
function a = infinit()
go = true ;
while go
a = 1 ;
end
end
and this is the code :
parpool(1) ;
f = parfeval(@infinit,1) ;
% looking for the code line that can stop the function,
value = fetchOutputs(f) ;
I know that "cancel" can actually stop, but then we can't get the output. I have also tryed by using a global variable, or a public variable with app designer, but both of those way are not working. From my research so far, it seems there is no solution. But still I hope that someone has maybe found an idea ! ;)
Otherwise, I actually want to run a function in app designer that is reading data from a sensor periodically. Meanwhile the code is doing something else until the user has finished the experiment. Then I want to get the data from the function. I guess maybe there might be a workaround ?
I thank you all in advance for your help !
Thomas
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!