Terminate an application called by system() after fixed amount of time
17 次查看(过去 30 天)
显示 更早的评论
Hello,
I have an application that interfaces with a third party software and receives UDP datagrams in real time. The application, when opened, stays open indefinitely and does not terminate. I want to read the output of the program and save numerical data to the MatLab workspace in real time.
The only way I can think of doing this is to open and close the application iteratively in a loop, saving the output (which prints in the command window) using diary, then reading the output with another script that pulls out the numerical values I want and save them in MatLab.
The issue I'm having is that the application does not terminate on its own. It stays open indefinitely and does not accept and user input. When run in MatLab using system(), it stays open until I break it using Control+C. How do I implement code in MatLab to terminate an application that is currently occupying the command window?
The furthest I got in the past few days of research has been to use the parallel computing toolbox, and use parfeval to asynchronously insert some kind of break after running a separate timer function inside of a loop under parfor.
I'm by no means an expert MatLab user but there has to be a way to make an application time out or stop in MatLab after it begins running, without using control+C.
Here is the application that I am trying to call and close on a time basis in MatLab:
0 个评论
采纳的回答
Nagarjuna Manchineni
2017-6-20
See the following link that discusses on how to create and kill the process after some time:
In addition to the above implementation, you can use the 'timer' function to create a timer object that executes the desired functionality after a certain time (mentioned while creating the timer object). You can use that to kill the spawned process if it still running after your desired time.
See the following documentation link for more information on timer class:
1 个评论
Sajid Afaque
2019-12-18
But what if i only have to wait and kill only for some iteration ?
i dont want to wait so long for all the iteration.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!