• API Main Page
  • Documentation
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

matlab/mex/signaldistmatrix.c

Go to the documentation of this file.
00001 
00024 #include "mex.h"
00025 #include "mex_utils.h"
00026 
00027 #include <stdlib.h>
00028 #include "array.h"
00029 #include "distances.h"
00030 
00031 
00032 void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]){ 
00033   char msg[2000];
00034   const char *docstring = 
00035      "signaldistfunction Pointwise distance Matrix between two signals.\n"
00036      "[ distmat ] = signaldistfunction( signal1, signal2 );\n"
00037      " Calculate a euclidean distance matrix.\n\n"
00038      "[ distmat ] = signaldistfunction( signal1, signal2, metric, ... );\n"
00039      " Calculate a distance matrix with another metric.\n"
00040      " Valid values for metric are:\n"
00041      " 'euclidean', ...\n"
00042      " You can pass additional parameters for the distance function along.\n";
00043   
00044   /* check proper input and output */
00045   if(nrhs<2){
00046     sprintf(msg, ">> Need at least 2 inputs.\n%s\n", docstring);
00047     mexErrMsgTxt(msg);
00048   } else if(!mxIsDouble(prhs[0]) || !mxIsDouble(prhs[1])){
00049     sprintf(msg, ">> First and second Input must be double arrays.\n%s\n", docstring);
00050     mexErrMsgTxt(msg);
00051   } 
00052 
00053   /* getting the appropriate array representation */
00054   Array *s1 = mex_mxarray_to_array( prhs[0] );
00055   Array *s2 = mex_mxarray_to_array( prhs[1] );
00056 
00057   /* computation */
00058   Array *d=distmatrix_signaldist( vectordist_euclidean, s1, s2, NULL, NULL );
00059   plhs[0]=mex_array_to_mxarray( d ); 
00060 
00061   /* cleaning up */
00062   array_free( s1 );
00063   array_free( s2 );
00064   array_free( d );
00065 
00066   return;
00067 }
00068         

Generated on Fri Jun 25 2010 14:10:16 for libeegtools by  doxygen 1.7.0