How can I run a .m-file with an endless loop and use the command window at the same time?
1 次查看(过去 30 天)
显示 更早的评论
Hello everyone,
I have a .m-file with an endless loop, which executes some functions. I also have a basic GUI, so that I can add/delete functions in the loop while the loop is running. While the endless loop is running, it is not possible to see the variables in the command window or to execute any other function in the comand window. Now the question is: Is there any possible way to run a .m-file with an endless loop and use the command window at the same time? OR Could you recommend another method, so that I can run some functions in the background repeatedly and use the command window at the same time?
Thanks
0 个评论
回答(3 个)
Sebastian Holmqvist
2012-7-12
A not-so-pretty solution would be to include a pause(0.001) at the end of each loop. I use it to allow my GUI to render some text before it starts with the heavy computing. I imagine it would give at least a few cpu cycles each iteration for you to manouver around the rest of the GUI.
0 个评论
Jason Ross
2012-7-12
Ideas:
- Run multiple MATLAB sessions. One with the GUI, the other doing something else. This assumes that the something else does not relate to what you are processing in the GUI.
- Look into using the Parallel Computing Toolbox to submit the desired computations to a single worker, or set of workers, and then give the results when you are done (or resubmit a new job, the same job, etc). If you have PCT, you can use up to 12 local workers on your machine using the "local" scheduler. Take a look at the "batch" command, it's probably the most straightforward way to get your feet wet, then other commands like spmd, parfor, and the job/task interface.
0 个评论
Jan
2012-7-12
Using the commandline during Matlab runs cannot work: Imagine that you could modify (or delete) a function, which is used inside the loop, and remove it by clear from the memory. There are more less obvious obstacles, which will not allow an inside-session mutli-threading in the future also.
Jason's suggestion to run mutliple Matlab sessions seems to be the most powerful and easy solution.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!