how to run 2 script .m at the same time in matlab?

6 views (last 30 days)
I want to run to execute 2 matlab script multiObject1.m and multiObject.m at the same time

Accepted Answer

Walter Roberson
Walter Roberson on 1 Dec 2015
Edited: Walter Roberson on 1 Dec 2015
Well, if you really need to do that (the cases are fewer than one might expect) then you will need to use the Parallel Processing Toolbox, and use either parfor or spmd. If the two will need to communicate with each other than spmd would be recommended.
However, when people say they need to run two scripts at the same time, they often mean that one script has to be able to gain control temporarily, do a bit of work, and then allow the other script to continue. It is not uncommon to be able to program that with callbacks of various kinds of events without needing the Parallel Processing Toolbox.
  7 Comments
Guillaume
Guillaume on 1 Dec 2015
No, it will not work. As Walter said, only one script at a time can update what is shown on screen.
To do what you want you'll need to have:
  • main code (script) in charge of displaying both processed video frames at the same time
  • 1st background script in charge of processing the video from one angle. Has to communicate with main code to give it the processed frame when done
  • 2nd background script in charge of processing the video from the 2nd angle. Also has to communicate with main code to give it the processed frame when done
If you don't have the parallel toolbox, then the background scripts would have to be called sequentially on each video frame and display may be far from real time.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!