How can I run a .m-file with an endless loop and use the command window at the same time?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (3)
Sebastian Holmqvist
am 12 Jul. 2012
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 Kommentare
Jason Ross
am 12 Jul. 2012
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 Kommentare
Jan
am 12 Jul. 2012
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 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!