Filter löschen
Filter löschen

run .exe file of c++ from matlab with change input value

2 Ansichten (letzte 30 Tage)
abbas hasan
abbas hasan am 4 Jun. 2014
Kommentiert: dpb am 4 Jun. 2014
i has a.exe file that i got form compile c++ code in microsoft visual studio 2010. i try to run this a.exe file from matlab, but i put this file to work in loop with another .m file write in matlab.
the idea is to run .m file in matlab with for loop . first the matlab file work with first value of the loop and after run a.exe file inside matlab with the same value and an so on. i used sprintf to generate string of input for .exe file as explain below :
wvl=0.4,
for ii=1:100 wvl=0.4+i*0.01;
... here there are another part of matlab code to do some calculations and prepare input data file for c++ code
str=sprinf('a.exe,%f',wvl);
system (str);
end
i am already used command line argument in c++ code to run the executable file with different values as explain:
int main(int argc, char *argv[]);
wvl=atof ( argv[1]);
cout << "wvl=" <<wvl<< endl;
the value (wvl) mentioned above i would like to change after compile the code.
i don't know when the error exact in c++ code or in matlab code, because i got on wrong results.
i will be greatful to any help.
  1 Kommentar
dpb
dpb am 4 Jun. 2014
I "know nuthink" to speak of about C++ but the above appears to my untrained eye to be ok w/ the exception I see no declaration for wv1--I'd've thunk that would cause a compilation problem altho again I don't know C/C++ well enough to recall what would occur by default presuming it were missing. (Unlike Fortran, in which lacking an 'implicit none' statement, the variable would be default float, unequivocally.)
Can you successfully run the program directly at the command line?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Call C++ from MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by