Home > other >  Starting external solver again after given elapsed time
Starting external solver again after given elapsed time

Time:07-16

I am trying to restart external solver after given elapsed time (3600 sec) but I am not successful, therefore I would like to ask you for help. Below is my code example. A problem is that first run is in operation and therefore if-else statement which would restart it is not taken in to account.

clc
close all 
clear all

tic 
! "C:\Program Files\external_solver.exe" -i file1.dat -o file1.out
et = toc 
if et > 3600; 
    ! "C:\Program Files\external_solver.exe" -i file1.dat -o file1.out 
end
;

Best regards Michal

CodePudding user response:

Assuming "C:\Program Files\external_solver.exe" -i file1.dat -o file1.out is a valid command, you can append an Ampersand '&' to it for your MATLAB script to continue while the other program executes.

Then, just make MATLAB wait for the amount of time you want, and kill the process in case it is still running. For example:

system('"C:\Program Files\Google\Chrome\Application\chrome.exe" &');
pause(10);
!taskkill -f -im chrome.exe
  • Related