[英]run .exe file of c++ from matlab with change input value
I have a.exe
file that I got from compiling C++ code in Microsoft Visual Studio 2010. I tried to run the a.exe
file from Matlab, but I put this file to work in loop with another .m
file written in Matlab. 我有a.exe
从Microsoft Visual Studio 2010中编译C ++代码获得的a.exe
文件。我尝试从Matlab运行a.exe
文件,但我将此文件与另一个用Matlab编写的.m
文件循环使用。
The idea is to run the .m
file in Matlab inside a for
loop . 这个想法是在for
循环内在Matlab中运行.m
文件。 First, the Matlab file works with the first value of the loop and after that runs a.exe
file inside Matlab with the same value and so on. 首先,Matlab文件使用循环的第一个值工作,然后在Matlab中以相同的值运行a.exe
文件,依此类推。 I used sprintf
to generate string of input for .exe
file as explained below: 我使用sprintf
为.exe
文件生成输入字符串,如下所述:
wvl=0.4,
for ii=1:100 wvl=0.4+i*0.01;
There are another part of Matlab code to do some calculations and prepare input data file for the C++ code: Matlab代码的另一部分可以进行一些计算并为C ++代码准备输入数据文件:
str=sprinf('a.exe,%f',wvl);
system (str);
I am already using the command line arguments in C++ code to run the executable file with different values: 我已经在C ++代码中使用命令行参数来运行具有不同值的可执行文件:
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 compiling the code. 我想在编译代码后更改上面提到的wvl
值。
I don't know if the error is in the C++ code or in the Matlab code, because I got the wrong results. 我不知道该错误是C ++代码还是Matlab代码,因为我得到了错误的结果。
Build it as a Matlab EXecutable (MEX) file. 将其构建为Matlab可执行(MEX)文件。 It can take input arguments like a Matlab function. 它可以像Matlab函数一样接受输入参数。
http://www.mathworks.de/de/help/matlab/matlab_external/introducing-mex-files.html http://www.mathworks.de/de/help/matlab/matlab_external/introducing-mex-files.html
Your question is a little bit ambiguous: You tried to run the a.exe, but put this file to work? 您的问题有点模棱两可:您试图运行a.exe, 但可以使用此文件吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.