I am using MATLAB to write text files that are executed by another program, MODTRAN. My program calls MODTRAN and runs, but it does not close the program; in fact, I must click yes for the program to close. This is coming to be a huge problem because I am going to be running a loop with at least 3000 cycles, and I can't have the screen pop up 3000 times and click yes all those times.
This is the code I use to call MODTRAN:
system('cd C:/users/.../mod5_64/ && start Mod5.2.0.0_cons.exe');
Attached is the screen that I see. The program will continue to run even if I don't click anything, so I will have many pop ups and it will probably crash my computer.
Is there a way for to code something in matlab that will either close this MODTRAN when it is done, or click yes when it asks?
Thank you!

 채택된 답변

Image Analyst
Image Analyst 2014년 2월 28일

1 개 추천

Can it be run as a COM server? If so, use ActiveX to launch it and shut it down. I've attached an ActiveX demo for Excel.
Or you can use my attached program to find the process in the task list and use system() and taskkill to forcibly kill it.

댓글 수: 3

Sam
Sam 2014년 2월 28일
Thank you. I couldn't figure out how to get run modtran with ActiveX. I used your code to find modtran in the task list. My question is, is there a way to only kill it when modtran is done with the process? The task list says modtran is still running as long as the window i attached above is still open. I want to be able to monitor when the dialog box appears and I want to have matlab choose "yes." Is that possible?
I'm not sure. If you can get the CPU time it uses and monitor that, and if it hits zero for a while then maybe you can assume it's done, but maybe not. There is nothing where an app tells the operating system "I'm done now and I'm idle" so I think that monitoring the CPU time it's using, if that is even possible, which I don't know, is the only way.
It is possible to monitor the cpu-usage with PsList, which is free at Sysinternals.
str = evalc( 'system( PsList name/PID )' );
Better resolution and easier to parse than TaskList

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

per isakson
per isakson 2014년 2월 28일
편집: per isakson 2014년 2월 28일

1 개 추천

If on Windows and you don't find any solution. Last resort is the DOS command taskkill. If you run several MODTRN simultaneously then you must know which to kill.

카테고리

태그

아직 태그를 입력하지 않았습니다.

질문:

Sam
2014년 2월 28일

댓글:

2014년 3월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by