Access variables in parallel computing
显示 更早的评论
Hello everyone,
I have a problem that I'm unsure how to solve:
I have a video camera recording during a task that gives a TTL signal per frame (approx 75 Hz) that I would like to count in the background while the main task is running. However to synchronize the signals I would like MATLAB to access the counter variable at certain points during the task and return the frame number. I have tried using the parallel computing toolbox, however I do not know how to access the counter variable in the background. Is there any way of doing this on one machine or how could this be best achieved?
Thanks in advance for the help,
John
3 个评论
Raymond Norris
2022-4-5
You want a background task to count TTL signals from a video camera recording. You want the main task to poke the background task everyone once and while to get the current frame number. More specifically, you don't want the background task to "broadcast" out the current frame to the main task -- the main task will ask for it when it needs it. Is that all correct?
In a moment in time, if the main task asks for the current frame number, by the time the background task receives the request, there current frame number could have changed several times. Or how close to real time does this have to be?
Do you have the Parallel Computing Toolbox? Which version of MATLAB are you running?
John Tuff
2022-4-5
Alice
2024-6-18
Hi,
A bit late, but I have the same question : I need to access a variable in my main program that is being modified in the background. I can access it sometimes but it will stop updating the variable after some time and give me a constant value when the actual variable is changing, so I think that I'm not going about it the right way.
How did you solve your problem?
Thanks in advance,
Alice
回答(2 个)
Steven Lord
2022-4-4
0 个投票
2 个评论
John Tuff
2022-4-4
Steven Lord
2022-4-4
Doesn't this paragraph from the documentation page address that?
"Use parfeval with the background pool to run a function in the background. parfeval immediately returns a Future object that represents the function running in the background. To get results from the Future, call fetchOutputs."
类别
在 帮助中心 和 File Exchange 中查找有关 Parallel Computing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!