Calling c++ routines in Matlab -
i've got long code in c++ , want call matlab.
i read that, using mex-files, calling large pre-existing c/c++ , fortran routines matlab without rewriting them matlab functions possible.
however, mex files cumbersome , apparently 1 should change whole code. furthermore, have problems in calling c/c++ compiler matlab's command line. in particular, matlab asks
select compiler: [1] lcc-win32 c 2.4.1 in d:\progra~1\matlab\r2013a\sys\lcc [2] microsoft visual c++ 2010 in d:\program files\microsoft visual studio 10.0 but code written in borland c++ matlab not recognize borland compiler.
is there way, simpler i'm doing, integrate c/c++ codes in matlab mex-files?
as mentioned user2485710, should use mex interface call existing c++ code. mex interface wrapper around existing c++ code.
for example, if called call add.c, adds 2 numbers, not able call directly in matlab. wrapper should this,
#include "mex.h" void mexfunction( int nlhs, mxarray *plhs[], int nrhs, const mxarray *prhs[]) { // standard gateway function double *a = mxgetpr(prhs[0]); double *b = mxgetpr(prhs[1]); double c = add(a,b); mxsetpr(plhs[0], &c); } this illustrative example, might have read documentation each of functions have used. need not worry compiler. c++ programs work in compilers. choose 1 of compilers in list , work it. there limitations, not know of hit usecase.
Comments
Post a Comment