394 Accelerating MATLAB
®
Performance
8.1.3 MEX Function Inputs and Outputs
As noted above, the MEX gateway function mexFunction() is dened as follows:
void mexFunction (
int nlhs, /* number of expected outputs */
mxArray *plhs[], /* array of pointers to output args */
int nrhs, /* number of input args */
const mxArray *prhs[]) /* array of pointers to input args */
The format is simple: a pair of gateway inputs that denes the MEX function’s outputs
(number of requested arguments and a corresponding array of pointers to them), and
another pair that denes the MEX function’s inputs (number of specied arguments
and an array of pointers to them). MATLAB automatically sets mexFunction’s input args
(nlhs etc.) based on the actual inpu