Call exe program with input in Matlab(under cmd Environment)

In summary, the user is asking for help in controlling an external program through MATLAB. They have tried using the "system" command, but are struggling to add command-line parameters or input data into the program. Another user suggests using a batch file to solve the problem. The original user thanks them and confirms that their issue has been resolved.
  • #1
alima2065
2
0
Hi
I write M-file that call 'Program.exe' by SYESTEM command and go to the Program.exe Environment .now i need apply a command of 'Program.exe'. But i cannot control application with Matlab because Matlab go to 'Program.exe' Environment and 'Program.exe's command only is Executable and it is not automatically.

Thanks

Ali
 
Physics news on Phys.org
  • #2
Welcome to PhysicsForums!

Are you asking how to add command-line parameters to DOS-style commands? If so, you can do that with the dos command:
http://www.mathworks.com/help/techdoc/ref/dos.html

If you're asking how to put input into the program once launched, that may be more difficult. It probably depends on how the program is structured (or, even easier, whether the program can take read in input from a textfile or some such).

A batch file can also be quite powerful:
http://www.google.ca/search?q=write+batch+file+windows
 
  • #3
MATLABdude said:
Welcome to PhysicsForums!

Are you asking how to add command-line parameters to DOS-style commands? If so, you can do that with the dos command:
http://www.mathworks.com/help/techdoc/ref/dos.html

If you're asking how to put input into the program once launched, that may be more difficult. It probably depends on how the program is structured (or, even easier, whether the program can take read in input from a textfile or some such).

A batch file can also be quite powerful:
http://www.google.ca/search?q=write+batch+file+windows

MATLABdude thank you very much. my problem solved by batch file.
best regards
 

Related to Call exe program with input in Matlab(under cmd Environment)

1. How do I call an executable program with input in Matlab under the cmd environment?

To call an executable program with input in Matlab under the cmd environment, you can use the "system" function. This function allows you to execute an external program from within Matlab and pass input arguments to it.

2. What is the syntax for calling an executable program in Matlab?

The syntax for calling an executable program in Matlab is:
system('program_name.exe input_argument1 input_argument2')

3. How do I specify the path of the executable program in Matlab?

To specify the path of the executable program in Matlab, you can either use the full path to the program or add the program's directory to the system path using the "setenv" function. This will allow you to call the program from any directory in Matlab.

4. Can I pass multiple input arguments to the executable program in Matlab?

Yes, you can pass multiple input arguments to the executable program in Matlab by separating them with a space in the system function. For example:
system('program_name.exe input_argument1 input_argument2')

5. How do I handle the output from the executable program in Matlab?

You can handle the output from the executable program in Matlab by assigning the output to a variable using the "[status, result] = system()" syntax. The "status" variable will contain the exit status of the program, and the "result" variable will contain the output from the program.

Similar threads

Replies
19
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
13K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
6K
  • Programming and Computer Science
Replies
12
Views
9K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
10K
Back
Top