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