Run multiple for loops in separate functions simultaneously?
Show older comments
I've been cobbling together a control program for a system and trying to build it into a nice and easy to use graphical interface, but I'm a bit past my depth of understanding and need some advice.
I essentially have a function, moveMotors() that sends coordinates to an arduino to move a pair of stepper motors and acquire a column of data, data = acquireData(), at different indexed locations. I then want to send that data matrix through another set of functions to do some conditiong and then plot it as it's acquired. But while the moveMotors() function is running, I can't run other functions unless I call them inside one my moveMotors() for loops.
The root of the question is: how can I have multiple functions running simultaneously and still pass data between them? I know you can write to and read from user interface work spaces with setappdata() and getappdata() and the appropriate handles, but I don't know of a way to do this and run functions in parallel.
Thanks all.
Answers (1)
Sean de Wolski
on 8 Aug 2016
0 votes
Use a timer. The timer will periodically fire calling the arduino method which can then call a plot update as necessary. I'd do this with Nested Functions for data management.
Categories
Find more on MATLAB Support Package for Arduino Hardware 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!