How to execute parallel functions ?
显示 更早的评论
Hi everyones,
I have a three buffer system and It takes 3 steps : - I need to collect data from a .txt file - I need to filter these data - I need to plot the filtered data
I want to do these three steps simultaneously ! (even if I have a delay between current data and plotted data) Should I use a parfor loop, matlabpool or multi-thread programming ?
Thanks a lot !
采纳的回答
更多回答(4 个)
Paul-Henri Michel
2013-4-23
0 个投票
11 个评论
I dont see if this can parallelized at all. Each steps requieres that the previous step is done. So how can you start plotting while you are still reading the file? Is it really one file you read or multiple? How big is the file? How long does you code run now to accomplish these there steps?
Paul-Henri Michel
2013-4-23
编辑:Paul-Henri Michel
2013-4-23
The first problem will be that you can't plot from a worker. The second problem is that MATLAB itself doesn't operate in Real-Time (only xPC Target and Real-Time-Windows Target do). For the worker communication you can use functions like labsend, labreceive, labbarrier etc.
I think what might work is to start 3 workers where each worker operates on his own file and does all 3 steps. You would need to save the .fig file from the worker so that you can open and display the figure later on.
But you won't be able to see a "live" graphic from the worker.
Paul-Henri Michel
2013-4-23
编辑:Paul-Henri Michel
2013-4-23
Friedrich
2013-4-23
Yes, no real-time. Mostly related to the Operating Systems are not real time at all. There are two toolboxes which work in real time (mentioned above) but there you can't plot and they are Simulink based.
Are you sure you really need real time? So far it sounds more like as fast as possible (a.k.a. "live") is enough.
Paul-Henri Michel
2013-4-23
Mhh, the main problem here is Parallel Computing Toolbox because you can't display/update a figure. That plotting really needs to be done in MATLAB itself, which means some timer/task is needed. However when you start a long calculation in MATLAB the timer callback isn't executed as long your code doesn't use any drawnow/pause or other commands which let the event queue update. Which means the figure isn't updated as long your other code is running.
Paul-Henri Michel
2013-4-23
编辑:Paul-Henri Michel
2013-4-23
Friedrich
2013-4-23
When starting 2 MATLABs why communicate anyway? Simple use one MATLAB to run the code and display the results and use the other one for your normal work. I don't see a need for the two MATLABs to exchange any data/information.
Paul-Henri Michel
2013-4-23
编辑:Paul-Henri Michel
2013-4-23
Friedrich
2013-4-23
Plotting doesnt take much time. Using a MATLAB for Plotting only seems a bit too much. I would do all that in one MATLAB. You can use PCT to read in the 3files and post process it. You then use these results and plot it and then start over again. This can run in 1 MATLAB.
You use the second MATLAB for your own.
Paul-Henri Michel
2013-4-23
0 个投票
2 个评论
Friedrich
2013-4-23
Why do you need the same workspace? You can put the data together later on.
Paul-Henri Michel
2013-4-23
类别
在 帮助中心 和 File Exchange 中查找有关 Parallel Computing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!