Running two functions in Parallel

1 回表示 (過去 30 日間)
Aakash
Aakash 2013 年 8 月 16 日
Hello everyone, I have following situation: I am running a simple simulation of motion. A point mass moving at a constant velocity in XY plane. Now, I need to call a function to capture an image. Image capturing function takes about 2 seconds. I need first simulation (motion) keep on running while running the image capturing function. Is there any parallel computing tool in MATLAB that could be run without hindering simulation platform? Please advise. Many thanks.

回答 (2 件)

Ken Atwell
Ken Atwell 2013 年 8 月 16 日
Parallel Computing Toolbox's batch capability may do the trick for you. Fire off the image capture as a batch job while performing the simulation in the main process.
  1 件のコメント
Aakash
Aakash 2013 年 8 月 17 日
Thanks very much Ken. Opening of batch program is quite time consuming!! Even for simple functions! it is taking significant time in MATLAB! This is not suitable for my first section of code. I was thinking of using 'parfor', would you be able to tell me how to set equal times for all statements inside 'parfor'. Thanks again.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2013 年 8 月 17 日
You cannot set equal times for statements inside parfor()
You should consider using a timer()
Note: a timer sounds like all you would need in your situation. Timers can interrupt between any two lines of MATLAB source. Unless you are doing uninterpretable real-time work in the simulation, you likely do not need parallelism.

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by