How to execute parallel functions ?
Show older comments
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 !
1 Comment
Paul-Henri Michel
on 22 Apr 2013
Accepted Answer
More Answers (4)
Paul-Henri Michel
on 23 Apr 2013
0 votes
11 Comments
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
on 23 Apr 2013
Edited: Paul-Henri Michel
on 23 Apr 2013
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
on 23 Apr 2013
Edited: Paul-Henri Michel
on 23 Apr 2013
Friedrich
on 23 Apr 2013
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
on 23 Apr 2013
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
on 23 Apr 2013
Edited: Paul-Henri Michel
on 23 Apr 2013
Friedrich
on 23 Apr 2013
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
on 23 Apr 2013
Edited: Paul-Henri Michel
on 23 Apr 2013
Friedrich
on 23 Apr 2013
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
on 23 Apr 2013
0 votes
2 Comments
Friedrich
on 23 Apr 2013
Why do you need the same workspace? You can put the data together later on.
Paul-Henri Michel
on 23 Apr 2013
Paul-Henri Michel
on 23 Apr 2013
0 votes
Paul-Henri Michel
on 24 Apr 2013
0 votes
Categories
Find more on Parallel Computing Toolbox 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!