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!