Terminate an application called by system() after fixed amount of time

15 vues (au cours des 30 derniers jours)
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:

Réponse acceptée

Nagarjuna Manchineni
Nagarjuna Manchineni le 20 Juin 2017
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 commentaire
Sajid Afaque
Sajid Afaque le 18 Déc 2019
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by