Arguments to executable file

조회 수: 1 (최근 30일)
Nidhi SRIVASTAVA
Nidhi SRIVASTAVA 2017년 6월 26일
편집: Nidhi SRIVASTAVA 2017년 6월 26일
I am working on a conversion of IDL code to Matlab.
IDL --= spawn, dir_progs+'file.exe -M' + filedats+ '.dat -NMOD 5 -R -PARR' + dir_prog+'datafile.dat',/log_output
-M,-R,-PARR are the commands to control how it executes.
dir_progs - directory of file.
Can anybody help me to execute this code into MATLAB?
Thanks in advance.

채택된 답변

Walter Roberson
Walter Roberson 2017년 6월 26일
cmd = sprintf('"%s" -M"%s.dat" -NMOD 5 -R -PARR"%s"', fullfile(dir_progs, 'file.exe'), filedats, fullfile(dir_prog, 'datfile.dat'));
[status, output_log] = system(cmd);
Note: it is risky to have a variable named "dir_progs" and another one named "dir_prog" with only the final "s" different between the two -- there is a somewhat high risk of getting the two of them confused or of accidentally typing one when the other was wanted.
I made the string more robust by adding "" around names, in case there happen to be spaces in directory names.
There are some places in the string that I would tend to suspect should have a space separating parts, but it is possible that it is correct without those spaces; it depends on what the program expects.
  댓글 수: 2
Nidhi SRIVASTAVA
Nidhi SRIVASTAVA 2017년 6월 26일
편집: Nidhi SRIVASTAVA 2017년 6월 26일
Thanks a lot for the prompt response. Could you please explain what is obtained in the output_log? After running the code, I get a string array. Is it the contents in the .exe file?
Walter Roberson
Walter Roberson 2017년 6월 26일
The character vector output_log will contain whatever the .exe wrote out to standard output.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Search Path에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by