简体   繁体   中英

Starting external solver again after given elapsed time

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM