Exemplo n.º 1
0
void mexFunction( int nlhs, mxArray *plhs[],
                  int nrhs, const mxArray *prhs[] )
{
  double *y;
  double  x;

    /* Check arguments */
    
  if (nrhs != 1) { 
    mexErrMsgIdAndTxt( "MATLAB:timestwoalt:invalidNumInputs",
            "One input argument required."); 
  } else if (nlhs > 1) {
    mexErrMsgIdAndTxt( "MATLAB:timestwoalt:maxlhs",
            "Too many output arguments."); 
  } else if (!mxIsNumeric(prhs[0])) {
    mexErrMsgIdAndTxt( "MATLAB:timestwoalt:invalidInputType",
            "Argument must be numeric.");
  } else if (mxGetNumberOfElements(prhs[0]) != 1 || mxIsComplex(prhs[0])) {
    mexErrMsgIdAndTxt( "MATLAB:timestwoalt:inputNotRealScalar",
            "Argument must be non-complex scalar.");
  }
  /* create a 1-by-1 matrix for the return argument */
  plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL);

  /* get the scalar value of the input x */
  /* note: mxGetScalar returns a value, not a pointer */
  x = mxGetScalar(prhs[0]);

  /* assign a pointer to the output */
  y = mxGetPr(plhs[0]);
  
  /* call the timestwo_alt subroutine */
  timestwo_alt(y,x);
}
Exemplo n.º 2
0
void mexFunction(int nlhs, mxArray *plhs[],
                 int nrhs, const mxArray *prhs[])
{
  double *y1_t;
  double *y2_t;
  double x_t;

  /* Create a 1-by-1 matrix for the return argument. */
  plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
  plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);

  /* Get the scalar value of the input x. */
  /* Note: mxGetScalar returns a value, not a pointer. */
  x_t = mxGetScalar(prhs[0]);

  /* Assign a pointer to the output. */
  y1_t = mxGetPr(plhs[0]);
  y2_t = mxGetPr(plhs[1]);
  
  /* Call the timestwo_alt subroutine. */
  timestwo_alt(y1_t, y2_t,x_t);
}