How to make command line free while a program rans?
조회 수: 3 (최근 30일)
이전 댓글 표시
Imagine, I made a program that contineously executes loop FOR-END (a Watch, for example). I'd like to run another program while the first one is still running. However, the command line >> is busy. How to "free" it?
Of course, this is the problem of parallel computing. I am a newbile in it now. As far as I learned, there are several ways to start parallelization, either ">> pmode start" or ">> pool = parpool(2)". (I have two 'Workers').
Do I follow the right way?
After ">> pmode start" we get two-splitted Window with Lab1 and Lab2. How to submit a job to only one of them?
Looking forward,
Yevgeny
댓글 수: 7
Stephen23
2019년 8월 29일
편집: Stephen23
2019년 8월 29일
"Do you mean to make a GUI-envelope, Stephen?"
I have no idea what a "GUI-envelope" is.
I often use graphics callbacks to run code, thus keeping the command line "free" for me to do other things. Of course this requires writing a small GUI, but that is not very difficult.
"I tried this way, no succes."
As you did not show what you tried it is difficult for us to help you fix it.
"May be, I should use OOP-features in MATLAB?"
I don't see how OOP is related to the topic you are asking about.
채택된 답변
Walter Roberson
2019년 8월 29일
The only way to "free the command line" in MATLAB is to run your code with a timer, or in response to a callback (such as as a serial port bytes available function). The function that is run must return fairly soon, as the command line would not process commands while the function is running.
pmode does not free the command line. None of the facilities in the Parallel Computing Toolbox free the command line.
In some situations what is needed is not that the command line be freed, but instead that the user be able to trigger interactions while the code is running. In such cases it may be possible to build a GUI that has buttons or controls that allow parameters to be configured and then to trigger an action, with the action being executed in the context of a callback for the graphics object. For this to work, the main looping code that is executing must cooperate, by periodically permitting any pending callbacks to be executed, by calling pause() or drawnow() or waitfor() or uiwait()
추가 답변 (3개)
Jason Ross
2019년 8월 29일
You can use the batch function to send work to a parallel worker and then retrieve the results later. While the batch job is running, the command prompt is freed. If you want to send the job to only one worker you can specify that in the batch command.
Chidvi Modala
2019년 8월 29일
To submit a job to only one of the window, pmode is not the best fit. The commands you type at the pmode prompt in the Parallel Command Window are executed on all workers at the same time.
You can refer to following link to get more information
댓글 수: 0
Yevgeny Gayev
2019년 8월 30일
댓글 수: 2
Walter Roberson
2019년 9월 17일
Timers can interrupt the currently executing code at the end of any line of MATLAB code. They do not use a different thread for execution of the MATLAB code. It is not impossible that there is a different thread associated with scheduling them -- that would be an internal detail not exposed to the user.
You cannot set executionmode of a timer that is started. To change the execution mode of a timer, you must stop() the timer.
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!