00001 #include "mex.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 void timestwo_alt(double *y, double x)
00016 {
00017 *y = 2.0*x;
00018 }
00019
00020 void mexFunction( int nlhs, mxArray *plhs[],
00021 int nrhs, const mxArray *prhs[] )
00022 {
00023 double *y;
00024 double x;
00025
00026
00027
00028 if (nrhs != 1) {
00029 mexErrMsgTxt("One input argument required.");
00030 } else if (nlhs > 1) {
00031 mexErrMsgTxt("Too many output arguments.");
00032 } else if (!mxIsNumeric(prhs[0])) {
00033 mexErrMsgTxt("Argument must be numeric.");
00034 } else if (mxGetNumberOfElements(prhs[0]) != 1 || mxIsComplex(prhs[0])) {
00035 mexErrMsgTxt("Argument must be non-complex scalar.");
00036 }
00037
00038 plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);
00039
00040
00041
00042 x = mxGetScalar(prhs[0]);
00043
00044
00045 y = mxGetPr(plhs[0]);
00046
00047
00048 timestwo_alt(y,x);
00049 }
00050