How to RUN .exe file with Input file (example input.txt) in MATLAB

I want to run .exe file which takes input.txt as input file for processing the output. Can anybody help me to run .exe file with the input file ?

 Réponse acceptée

Durganshu
Durganshu le 9 Oct 2020
You can use the built in function system(command) to execute the given command in windows cmd (It also works in Linux). You may use system('"file.exe" argument1 argument2') where the file path of "input.txt" can be entered in the arguments. You may find more information regarding system in the MATLAB documentation.

4 commentaires

i faced this error.
Error using matlab.system.internal.executeCommand
Unrecognized option: E:\MATLAB\Data6\input.txt
Error in dos (line 66)
[varargout{1:nargout}] = matlab.system.internal.executeCommand(varargin{:});
Durganshu
Durganshu le 12 Oct 2020
Modifié(e) : Durganshu le 12 Oct 2020
What were your inputs? Please share the snippet of code.
Also, try to check in which directory are you working and from which directory are you taking inputs.
Program exe file and input.txt is in same working folder.
i wrote
filename = 'input.txt';
system('iri.exe', filename)
I remember using this command once or twice with the following command:
file = 'home/..../file.exe' %full path
val = [file, ' &']) %here, & pushes the command to the background
status = system(val fname)
This worked fine and I got no errors. You can skip the comma between .exe file and input file.
'Varargout' errors show up when the function does not have the proper output variable format.
You can go through following links for more details:
Hope that helps!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by