Run multiple for loops in separate functions simultaneously?
显示 更早的评论
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.
回答(1 个)
Sean de Wolski
2016-8-8
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!