Ejemplo n.º 1
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_Model model, model2;

   create_model_from_matlab(&model, prhs[0]);
   
   if (!lwpr_duplicate_model(&model2, &model)) mexErrMsgTxt("Cannot copy internally!");
   
   plhs[0] = create_matlab_from_model(&model);
   plhs[1] = create_matlab_from_model(&model2);   
   
   lwpr_free_model(&model);
   lwpr_free_model(&model2);   
}
Ejemplo n.º 2
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_Model model;
   char filename[MAX_PATH];
   int numErrors, numWarnings;
   
   if (nrhs!=1 || !mxIsChar(prhs[0])) mexErrMsgTxt("Second argument must be a filename (string).\n");

   mxGetString(prhs[0],filename,MAX_PATH);
   numErrors = lwpr_read_xml(&model, filename, &numWarnings);
   
   if (numErrors==-2) {
      mexErrMsgTxt("LWPR library has been compiled without support for reading XML files (depends on EXPAT)\n");
   } else if (numErrors==-1) {
      mexErrMsgTxt("Could not read XML file. Please check filename and access permissions.\n");
   } else if (numErrors>0) {
      mexErrMsgTxt("XML file seems to be invalid, error(s) occured.\n");
   } 
   
   if (numWarnings>0) {
      printf("Parsing XML file '%s' produced %d warnings.\n",filename,numWarnings);
   }
   
   plhs[0] = create_matlab_from_model(&model);
   
   lwpr_free_model(&model);
}
Ejemplo n.º 3
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_Model model;
   FILE *fp;
   char filename[MAX_PATH];
   int ok;
   
   if (nrhs!=1 || !mxIsChar(prhs[0])) mexErrMsgTxt("Second argument must be a filename (string).\n");

   mxGetString(prhs[0],filename,MAX_PATH);
   
   fp = fopen(filename, "rb");
   if (fp==NULL) {
      mexErrMsgTxt("Could not open the file. Please check filename and access permissions.\n");
   }
   
   ok = lwpr_read_binary_fp(&model, fp);
   if (!ok) mexErrMsgTxt("LWPR file seems to be invalid, error(s) occured.\n");
   fclose(fp);   
   
   plhs[0] = create_matlab_from_model(&model);
   
   lwpr_free_model(&model);
}