Last active
December 17, 2015 14:29
-
-
Save yansyaf/5624447 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "mex.h" | |
/* Input Arguments */ | |
#define X1 prhs[0] | |
#define X2 prhs[1] | |
/* Output Arguments */ | |
#define Y plhs[0] | |
void mexFunction( int nlhs, mxArray *plhs[], | |
int nrhs, const mxArray *prhs[] ) | |
{ | |
printf("adder\n"); | |
/* Check for proper number of arguments */ | |
if (nrhs != 2) { | |
mexErrMsgTxt("Two input arguments required."); | |
} else if (nlhs > 1) { | |
mexErrMsgTxt("Too many output arguments."); | |
} else { | |
printf("Adder from MEX function\n"); | |
} | |
//Allocate ouptut | |
Y = mxCreateNumericMatrix(1, 1, mxDOUBLE_CLASS, mxREAL); | |
//Adder function | |
*mxGetPr(Y) = *mxGetPr(X1) + *mxGetPr(X2); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment