The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: How to run .exe file from matlab
Replies: 8   Last Post: Jan 11, 2013 10:03 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Engin Uzunel

Posts: 8
Registered: 10/14/07
Re: How to run .exe file from matlab
Posted: Jan 9, 2013 11:13 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have similar problem. I have a simple fortran code (test.exe) which takes exponential of a number. I want to run this code several times from matlab as follows: open an input.dat file, write a number into it, call test.exe and then write the output to output.dat file.

The associated matlab code is as follows:

for n=1:10

input_val=rand(1,1); %creating a random number

fid_input = fopen('input.dat','w');
fprintf(fid_input, '%0.6f \n',input_val); % putting the number into input file

system ('test.exe') ;

fid_y = fopen('output.dat','r');
output_val=fscanf(fid_y,'%f'); % reading the output value from the output file


When I compile the fortran code on a 32 bit machine and then run the above matlab code on 32 bit matlab installed on 32 bit machine it works. However, if I compile the fortran code on a 64 bit machine and then run the above matlab code on 64 bit matlab installed on 64 bit machine it does not work! What can be the reason?
Any help is appreciated.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.