automatic execution of external program

Hi to everybody! I need to execute an external program (like a.exe) via matlab. Specifically, I need to change the folder in a cmd.exe window, execute the program a.exe and do the following input (these are do via successfully iteration and not via command line when the program is launched): - a number (return command); - the input file path (return command); - the input file (return command). I need to do this automatically because I need to execute the program hundred or thousand times with different inputs. Furthermore, I need to transfer the information produced in the cmd window in matlab command window because, in the case of some errors occurs, the program prints this in the cmd window.
If I don't do this, how I can do it via an external file, like .bat file?
thanks to everybody

답변 (2개)

Image Analyst
Image Analyst 2015년 3월 29일

1 개 추천

See attached demo (which launches Photoshop) that you can modify as needed.

댓글 수: 4

thanks, but in my cases it doesn't work
Image Analyst
Image Analyst 2015년 3월 30일
"doesn't work" is SO descriptive. ;-)
Do you want any more help?
OK, how about your MATLAB program writes the data out to a .mat file? Then instead of getting the return value from the command line in subsequent runs, you simply read it from a .mat file.
the program produces 50 text files for each call; in the next days I will talk about the problem with those who produced the executable (has source files) in order to improve their integration in matlab
Image Analyst
Image Analyst 2015년 3월 31일
Why can't your program just read in the text file(s) that are created? That should work.

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

Geoff Hayes
Geoff Hayes 2015년 3월 29일

0 개 추천

Simone - consider using the system or dos functions to execute the external program. You may be able to use the cmdout output parameter from either to capture the information produced in the cmd window.

댓글 수: 4

Geoff Hayes
Geoff Hayes 2015년 3월 29일
Simone's answer moved here
thanks for the quickly answer, but this don't solve my problem also with option '-echo' because it needs always the user interaction for the input and I need something of automatic.
Geoff Hayes
Geoff Hayes 2015년 3월 29일
Simone - you may have to describe in more detail what you are attempting to do with respect to the user interaction.
ok, first of all I need to launch the program and view the output parameters: in this case, system function with cmdout is the best; now, the program asks me a number and wait for the return command; then, the input file path with return command and the input file name, return command. All these request are made in successive line and I can't pass it as parameters when I call the program. Since this program will be launch hundred or thousand of times during a simulation, I need something of automatic that catch the informations from a .m file and launch the program in an iterative way because I can't ask to the user to insert the information all of time. I hope to be clearly.
Geoff Hayes
Geoff Hayes 2015년 3월 31일
Simone - please given an example of how the program asks me a number and wait for the return command. How will you know that the program is asking (and so waiting) for a response>

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

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2015년 3월 29일

댓글:

2015년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by