Stop an infinit function that is running in parallel with the remaining code, and get the outputs
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!