Multithreading to control several devices through matlab realtime

5 次查看(过去 30 天)
Hey People
I am an experimentalist physicist and I have built an extensive set of functions in matlab to control my experiment. In general my experiment involves controlling several different equipment and I have interfaced all of them have built classes for them. All has been good so far and I am very happy about the performance. But now I need to control several of these equipment in parallel and that is where I am stuck. I searched on the web for multi-threading matlab, and I found alot of stuff about multithreaded computing in matlab. However I did not find anything where I could have several threads and pass messages between them. I appreciate any kind of hint or tips.

回答(1 个)

Walter Roberson
Walter Roberson 2016-3-7
The Parallel Computing Toolbox "spmd" facility is more or less that. You use labSend() and labReceive() to transfer data between workers.
  4 个评论
AJ1
AJ1 2016-3-8
Thans for reply. It is really getting close to what I am looking for. However, this code still blocks the command line and I am unable to communicate with the threads through the command line. I might be able to just use some shared variables to communicate with the threads, but still I need to access the command line. Any idea?
Walter Roberson
Walter Roberson 2016-3-12
By the way, I saw some information a couple of days ago indicating that you need to feval() function handles in parallel processing rather than just call them. At the moment I do not remember the reasoning.
At the moment the only way I can think of to run asychronously and still have access to the command line is to use parfeval(), but I don't think that allows communication between workers.
The only way I can think of at the moment to do shared variables between workers is to use the File Exchange contribution "sharedmatrix" which uses operating system shared memory primitives.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by