#include "mex.h" extern "C" void foo(double *a, double *b, double *c, int n); void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { double *a = mxGetPr(prhs[0]); double *b = mxGetPr(prhs[1]); int n = mxGetN(prhs[0]); mxArray *m_c = mxCreateDoubleMatrix(1, n, mxREAL); double *c = mxGetPr(m_c); foo(a, b, c, n); plhs[0] = m_c; }