f



How to run exe. file from matlab

Hi, 
I want to run an exe file inside an .m file and I want it to get the input programmatically, i.e. without opening the exe file and manually entering the input's path (the exe asks for the path of the input). So here is what I have tried so far but I get errors: 

fname =  'C:/Mysoftware/for006';
system  (['C:/Mysoftware/Myexecutable.exe<' fname]); 
Can anybody help me please? 
0
mahdi747 (14)
7/11/2013 3:30:14 AM
comp.soft-sys.matlab 211266 articles. 25 followers. lunamoonmoon (257) is leader. Post Follow

11 Replies
964 Views

Similar Articles

[PageSpeed] 39

That looks like it should work... can you post your error message?
0
cfweise (61)
7/21/2013 7:06:10 PM
"Chris " <cfweise@yahoo.com> wrote in message <kshbf2$nji$1@newscl01ah.mathworks.com>...
> That looks like it should work... can you post your error message?

Hi Chris, 
The message that I get in the command window is: 
status =
    12
Enter the input file name:
Unable to open this file. Try again
Enter the input file name:
Unable to open this file. Try again
Enter the input file name:

The input is a text file for the famous datcom.exe program that you might have heard of. 
Thank you. 
0
mahdi747 (14)
7/21/2013 11:27:06 PM
Try
system (['C:/Mysoftware/Myexecutable.exe<' file]); 

where file is a text file containing the name of the data file you are feeding your program:
contents of file:
              fname
Sounds weird but it might work.

I hope you are not attempting to develop ICBMs!
0
cfweise (61)
7/22/2013 8:32:16 AM
"Chris " <cfweise@yahoo.com> wrote in message <ksiqmg$2b9$1@newscl01ah.mathworks.com>...
> Try
> system (['C:/Mysoftware/Myexecutable.exe<' file]); 
> 
> where file is a text file containing the name of the data file you are feeding your program:
> contents of file:
>               fname
> Sounds weird but it might work.
> 
> I hope you are not attempting to develop ICBMs!

Thank you, you're awesome Chris, it worked! But after the initial part of the exe is run, I get the message: 
Preparing to start the big loop
At 1000
Return to main program from M01O01
Return to main program from M50O62
Return to main program from M02O02
Return to main program from M51O63
Return to main program from M57O71

(for every line of the input text which contains 5 lines)
Is it because the original code is in FORTRAN and I have to write any code to make it compatible? I don't have any problem when I run the exe manually. 
As far as I know datcom is for estimating the stability and control of airplanes. We can't fly those stuff here in Oregon ;) 
Thanks afresh. 
0
mahdi747 (14)
7/22/2013 12:06:17 PM
I also received the 
"Return to main program"
messages. 
I think the program runs in verbose mode by default but I don't think it's an error. Just compare the demo output to expected output to see if things ran ok. 

Have fun!

 
0
cfweise (61)
7/22/2013 12:52:07 PM
"Chris " <cfweise@yahoo.com> wrote in message <ksj9tn$68p$1@newscl01ah.mathworks.com>...
> I also received the 
> "Return to main program"
> messages. 
> I think the program runs in verbose mode by default but I don't think it's an error. Just compare the demo output to expected output to see if things ran ok. 
> 
> Have fun!
> 
>  
Thanks Chris. I'm very glad you also have the program. Is the demo output generated automatically after it's run like when I run it manually? I don't see any outputs in the folder. I'm sorry for my questions. I'm a rookie. 
Thanks a lot! 


     
 
0
mahdi747 (14)
7/22/2013 6:11:11 PM
Yes 

system('datcom.exe < myfile')

exectuted in the directory containing datcom, myfile and EX1.INP

 generates a file datcom.out (contents shown below).



  ****************************************************
  *    USAF STABILITY AND CONTROL  DIGITAL DATCOM    *
  *    PROGRAM REV. JAN 96   DIRECT INQUIRIES TO:    *
  *    WRIGHT LABORATORY  (WL/FIGC)  ATTN: W. BLAKE  *
  *      WRIGHT PATTERSON AFB, OHIO  45433           *
  *    PHONE (513) 255-6764,   FAX (513) 258-4054    *
  ****************************************************
1                         CONERR - INPUT ERROR CHECKING
0 ERROR CODES - N* DENOTES THE NUMBER OF OCCURENCES OF EACH ERROR
0 A - UNKNOWN VARIABLE NAME
0 B - MISSING EQUAL SIGN FOLLOWING VARIABLE NAME
0 C - NON-ARRAY VARIABLE HAS AN ARRAY ELEMENT DESIGNATION - (N)
0 D - NON-ARRAY VARIABLE HAS MULTIPLE VALUES ASSIGNED
0 E - ASSIGNED VALUES EXCEED ARRAY DIMENSION
0 F - SYNTAX ERROR

0******************************  INPUT DATA CARDS  ******************************

  $FLTCON NMACH = 1.0, MACH(1)=0.60, NALPHA = 11.0,                              
          ALSCHD(1) = -6.0, -4.0, -2.0, 0.0, 2.0,                                
                       4.0, 8.0, 12.0, 16.0, 20.0, 24.0,                         
          RNNUB=4.28E6$                                                          
  $OPTINS SREF=8.85, CBARR=2.48, BLREF=4.28$                                     
  $SYNTHS XCG=4.14, ZCG=-0.20$                                                   
  $BODY NX = 10.0,                                                               
    X(1)=0.0,0.258,0.589,1.260,2.260,2.590,2.930,3.590,4.570,6.260,              
    R(1)=0.0,0.186,0.286,0.424,0.533,0.533,0.533,0.533,0.533,0.533,              
    S(1)=0.0,0.080,0.160,0.323,0.751,0.883,0.939,1.032,1.032,1.032,              
    P(1)=0.0,1.00,1.42,2.01,3.08,3.34,3.44,3.61,3.61,3.61$                       
  $BODY BNOSE=1.0, BLN=2.59, BLA=3.67$                                           
 CASEID APPROXIMATE AXISYMMETRIC BODY SOLUTION, EXAMPLE PROBLEM 1, CASE 1        
 SAVE                                                                            
 DUMP CASE                                                                       
 NEXT CASE                                                                       
  $BODY ZU(1)= -.595,-.476,-.372,-.138, .200,                                    
                .334, .343, .343, .343, .343,                                    
        ZL(1)= -.595,-.715,-.754,-.805,-.868,                                    
               -.868,-.868,-.868,-.868,-.868$                                    
 CASEID ASYMMETRIC (CAMBERED) BODY SOLUTION, EXAMPLE PROBLEM 1, CASE 2           
 SAVE                                                                            
 NEXT CASE                                                                       
  $FLTCON NMACH=3.0, MACH(1)=0.9,1.4,2.5, RNNUB=6.4E6, 9.96E6, 17.0E6$           
 SAVE                                                                            
 CASEID ASYMMETRIC (CAMBERED) BODY SOLUTION, EXAMPLE PROBLEM 1, CASE 3           
 NEXT CASE                                                                       
  $FLTCON NMACH=1.0, MACH(1)=2.5, RNNUB=17.86E6, HYPERS=.TRUE.$                  
  $BODY DS=0.0$                                                                  
 CASEID HYPERSONIC BODY SOLUTION,  EXAMPLE PROBLEM 1, CASE 4                     
 NEXT CASE                                                                       
1          THE FOLLOWING IS A LIST OF ALL INPUT CARDS FOR THIS CASE.
0
  $FLTCON NMACH = 1.0, MACH(1)=0.60, NALPHA = 11.0,                              
          ALSCHD(1) = -6.0, -4.0, -2.0, 0.0, 2.0,                                
                       4.0, 8.0, 12.0, 16.0, 20.0, 24.0,                         
          RNNUB=4.28E6$                                                          
  $OPTINS SREF=8.85, CBARR=2.48, BLREF=4.28$                                     
  $SYNTHS XCG=4.14, ZCG=-0.20$                                                   
  $BODY NX = 10.0,                                                               
    X(1)=0.0,0.258,0.589,1.260,2.260,2.590,2.930,3.590,4.570,6.260,              
    R(1)=0.0,0.186,0.286,0.424,0.533,0.533,0.533,0.533,0.533,0.533,              
    S(1)=0.0,0.080,0.160,0.323,0.751,0.883,0.939,1.032,1.032,1.032,              
    P(1)=0.0,1.00,1.42,2.01,3.08,3.34,3.44,3.61,3.61,3.61$                       
  $BODY BNOSE=1.0, BLN=2.59, BLA=3.67$                                           
 CASEID APPROXIMATE AXISYMMETRIC BODY SOLUTION, EXAMPLE PROBLEM 1, CASE 1        
 SAVE                                                                            
 DUMP CASE                                                                       
 NEXT CASE                                                                       
0 INPUT DIMENSIONS ARE IN FT, SCALE FACTOR IS 1.0000
0
cfweise (61)
7/22/2013 6:41:07 PM
"Chris " <cfweise@yahoo.com> wrote in message <ksjuc3$6r0$1@newscl01ah.mathworks.com>...
> Yes 
> 
> system('datcom.exe < myfile')
> 
> exectuted in the directory containing datcom, myfile and EX1.INP
> 
>  generates a file datcom.out (contents shown below).
> 
> 
> 
I do the same thing but it doesn't generate any outcome most assuredly because the version that I have is 1976 and yours is 1996 as it says in the beginning of your generated report. 
So is it possible that I can also have the newer version? 
0
mahdi747 (14)
7/22/2013 10:25:17 PM
I accessed datcom.exe publicly from here:
http://www.pdas.com/datcomdownload.html
They have precompiled binaries for linux, pc and mac, or you can compile from source.
0
cfweise (61)
7/22/2013 10:56:06 PM
"Chris " <cfweise@yahoo.com> wrote in message <kskda6$fnc$1@newscl01ah.mathworks.com>...
> I accessed datcom.exe publicly from here:
> http://www.pdas.com/datcomdownload.html
> They have precompiled binaries for linux, pc and mac, or you can compile from source.

I realized what the problem is. It does generate the output, but  the darn thing is being saved in the main folder not where the datcom.exe is located. I accidentally noticed the files in C:/myfolder. 
Chris, you solved my problem. I don't know how to thank you for your help and patience; all I can say is, God bless you. 
0
mahdi747 (14)
7/23/2013 2:04:10 AM
Good luck with the calculations, Mehdi, have fun!
0
cfweise (61)
7/23/2013 7:35:14 AM
Reply:

Web resources about - How to run exe. file from matlab - comp.soft-sys.matlab

Undocumented Matlab
Undocumented, unsupported and hidden features in Matlab

Matlab Upazila - Wikipedia, the free encyclopedia
... 23°21′N 90°42.5′E  /  23.35°N 90.7083°E  / 23.35; 90.7083 Coordinates : 23°21′N 90°42.5′E  /  23.35°N 90.7083°E  / 23.35; 90.7083 Matlab ...

Open Directory - Science: Math: Software: MATLAB
The MathWorks - Developers of MATLAB, Simulink and Stateflow. Offers products for data analysis, visualization, application development, simulation, ...

MATLAB Mobile on the App Store
Read reviews, compare customer ratings, see screenshots, and learn more about MATLAB Mobile. Download MATLAB Mobile and enjoy it on your iPhone, ...

The Smart Emergency Response System Using MATLAB and Simulink - YouTube
In the aftermath of an earthquake, every second counts for disaster victims. Imagine a system that can locate people quickly and help first responders ...

The A-Z of Programming Languages: MATLAB
What prompted the development of MATLAB?

Matlab: Invalid .NET Framework. Either the specified framework was not found or is not currently supported ...
If you are trying to compile Matlab into .Net framework, you might encounter this message, even though you have the .Net framework installed ...

Matlab edges closer to electronic design automation world
Matlab, one of the world's most widely used products for algorithmic development, has long occupied its own niche far removed from EDA and hardware ...

Can I/How do I use DMTCP with a parallel pool of MATLAB workers? · Issue #223 · dmtcp/dmtcp · GitHub
dmtcp - DMTCP: Distributed MultiThreaded CheckPointing matlab -nodisplay -r "parpool('local',4); parfor i=1:10, pause(1); fprintf('%i ',i); end; ...

Using MATLAB and SDR to Reverse Engineer 433MHz Messages
... so he focused on studying the methodology and the tools available for analyzing 433MHz RF transmission. He describes the process of using MATLAB ...

Resources last updated: 3/8/2016 7:10:30 AM