Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to run exe. file from matlab

Subject: How to run exe. file from matlab

From: Mehdi

Date: 11 Jul, 2013 03:30:14

Message: 1 of 12

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?

Subject: How to run exe. file from matlab

From: Chris

Date: 21 Jul, 2013 19:06:10

Message: 2 of 12

That looks like it should work... can you post your error message?

Subject: How to run exe. file from matlab

From: Mehdi

Date: 21 Jul, 2013 23:27:06

Message: 3 of 12

"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.

Subject: How to run exe. file from matlab

From: Chris

Date: 22 Jul, 2013 08:32:16

Message: 4 of 12

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!

Subject: How to run exe. file from matlab

From: Mehdi

Date: 22 Jul, 2013 12:06:17

Message: 5 of 12

"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.

Subject: How to run exe. file from matlab

From: Chris

Date: 22 Jul, 2013 12:52:07

Message: 6 of 12

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!

 

Subject: How to run exe. file from matlab

From: Mehdi

Date: 22 Jul, 2013 18:11:11

Message: 7 of 12

"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!


     
 

Subject: How to run exe. file from matlab

From: Chris

Date: 22 Jul, 2013 18:41:07

Message: 8 of 12

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

Subject: How to run exe. file from matlab

From: Mehdi

Date: 22 Jul, 2013 22:25:17

Message: 9 of 12

"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?

Subject: How to run exe. file from matlab

From: Chris

Date: 22 Jul, 2013 22:56:06

Message: 10 of 12

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.

Subject: How to run exe. file from matlab

From: Mehdi

Date: 23 Jul, 2013 02:04:10

Message: 11 of 12

"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.

Subject: How to run exe. file from matlab

From: Chris

Date: 23 Jul, 2013 07:35:14

Message: 12 of 12

Good luck with the calculations, Mehdi, have fun!

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us