medfilt.cpp
Go to the documentation of this file.
1 #include "mex.h"
2 #include "../Mediator.h"
3 
4 /* The computational routine */
5 void arrayMedian(int windowsize, double *y, double *z, mwSize n)
6 {
7  mwSize i;
8  Mediator<double> mediator(windowsize);
9  for (i=0; i<n; i++) {
10  mediator.insert(y[i]);
11  z[i] = mediator.getMedian();
12  }
13 }
14 
15 /* The gateway function */
16 void mexFunction( int nlhs, mxArray *plhs[],
17  int nrhs, const mxArray *prhs[])
18 {
19  int windowsize; /* input scalar */
20  double *inMatrix; /* 1xN input matrix */
21  size_t nrows; /* size of matrix */
22  double *outMatrix; /* output matrix */
23 
24  /* check for proper number of arguments */
25  if(nrhs!=2) {
26  mexErrMsgIdAndTxt("MyToolbox:arrayProduct:nrhs","Two inputs required.");
27  }
28  /*if(nlhs!=1) {
29  mexErrMsgIdAndTxt("MyToolbox:arrayProduct:nlhs","One output required.");
30  }*/
31  /* make sure the first input argument is scalar */
32  if( !mxIsDouble(prhs[0]) ||
33  mxIsComplex(prhs[0]) ||
34  mxGetNumberOfElements(prhs[0])!=1 ) {
35  mexErrMsgIdAndTxt("MyToolbox:arrayProduct:notScalar","Input multiplier must be a scalar.");
36  }
37 
38  /* make sure the second input argument is type double */
39  if( !mxIsDouble(prhs[1]) ||
40  mxIsComplex(prhs[1])) {
41  mexErrMsgIdAndTxt("MyToolbox:arrayProduct:notDouble","Input matrix must be type double.");
42  }
43 
44  /* check that number of rows in second input argument is 1 */
45  if(mxGetN(prhs[1])!=1) {
46  mexErrMsgIdAndTxt("MyToolbox:arrayProduct:notColVector","Input must be a column vector.");
47  }
48 
49  /* get the value of the scalar input */
50  windowsize = (int) mxGetScalar(prhs[0]);
51 
52  /* create a pointer to the real data in the input matrix */
53  inMatrix = mxGetPr(prhs[1]);
54 
55  /* get dimensions of the input matrix */
56  nrows = mxGetM(prhs[1]);
57 
58  /* create the output matrix */
59  plhs[0] = mxCreateDoubleMatrix((mwSize)nrows,1,mxREAL);
60 
61  /* get a pointer to the real data in the output matrix */
62  outMatrix = mxGetPr(plhs[0]);
63 
64  /* call the computational routine */
65  arrayMedian(windowsize,inMatrix,outMatrix,(mwSize)nrows);
66 }
void arrayMedian(int windowsize, double *y, double *z, mwSize n)
Definition: medfilt.cpp:5
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Definition: medfilt.cpp:16
void insert(const Item &v)
Definition: Mediator.h:36
Item getMedian()
Definition: Mediator.h:91


timesync_ros
Author(s): Juraj Oršulić
autogenerated on Mon Jun 10 2019 15:28:33