How to simultaneously and continuously run multiple codes?

2 views (last 30 days)
I am trying to continuously run a simulation from MATLAB to Arduino(to receive and send information) and also have a GUI to interact with. The problem I am running into is trying to have one part of my code continuously running, call it A, and be able to have a simulation occur, call it B, while the A is still running. I looked into parallel computing and being able to have A and B running along with sending and receiving information from Arduino, but I believe there is something I am missing to simulate this. Has anyone ever tried this before? Also let me know if you need more detailed explanation.
My original plan was to create 6 scripts/functions: 1 be the communication portal for Arduino to MATLAB, the next would be my GUI, then my original code that always has to be running, the other three would be simulations preformed one at a time.
Thanks! (I currently have R2013a)

Answers (1)

Walter Roberson
Walter Roberson on 15 May 2014
Instead of having your code continually running to communicate with the Arduino, use serial port callbacks to talk to it as needed. See ReceivedBytesFcn and related serial properties.

Categories

Find more on Instrument Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!