MATLAB: Zero inputs in C-Mex-function

MATLABmex

Hello
Is it possible to have zero inputs in C-Mex-function. If so can anyone give me an example of having zero inputs and more than 1 output in the mex-function.
Thank you
Priyanka

Best Answer

// 0 inputs, any reasonable number of outputs (scalars 1, 2, ... etc)
#include "mex.h"
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
int i;
for( i=0; i<nlhs; i++ ) {
plhs[i] = mxCreateDoubleScalar(i+1);
}
}