필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
abbas hasan
abbas hasan 2014년 6월 4일
댓글: dpb 2014년 6월 4일
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
dpb
dpb 2014년 6월 4일
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?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Call C++ from MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by