void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { int dim; LWPR_Model model; const double *xn; double yn; double yp; double max_w; if (nrhs<4) mexErrMsgTxt("Too few arguments."); create_model_from_matlab(&model,prhs[0]); dim = (int) mxGetScalar(prhs[1])-1; if (dim<0 || dim>=model.nOut) mexErrMsgTxt("2nd parameter (dim) exceeds model size.\n"); xn = mxGetPr(prhs[2]); if (mxGetM(prhs[2])!=model.nIn || mxGetN(prhs[2])!=1) { lwpr_free_model(&model); mexErrMsgTxt("3rd parameter (center) does not match model dimensions.\n"); } yn = mxGetScalar(prhs[3]); lwpr_aux_update_one(&model, dim, xn, yn, &yp, &max_w); plhs[0] = mxCreateStructMatrix(1,1, SUB_FIELDS, SUB_FIELD_NAMES); fill_matlab_from_sub(&model.sub[dim], plhs[0], 0); plhs[1] = mxCreateDoubleScalar(yp); plhs[2] = mxCreateDoubleScalar(max_w); lwpr_free_model(&model); }
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); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { LWPR_Model model; char filename[MAX_PATH]; FILE *fp; int ok; if (nrhs<2 || !mxIsChar(prhs[1])) mexErrMsgTxt("Second argument must be a filename (string).\n"); create_model_from_matlab(&model, prhs[0]); mxGetString(prhs[1],filename,MAX_PATH); fp = fopen(filename, "wb"); if (fp==NULL) { mexErrMsgTxt("Could not open the file. Please check filename and access permissions.\n"); } ok = lwpr_write_binary_fp(&model, fp); fclose(fp); plhs[0] = mxCreateDoubleScalar(ok); lwpr_free_model(&model); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { int i; double *nrfs; LWPR_Model model; LWPR_Model *pmodel; if (nrhs<1) mexErrMsgTxt("Too few arguments."); pmodel = get_pointer_from_array(prhs[0]); if (pmodel == NULL) { create_model_from_matlab(&model,prhs[0]); pmodel = &model; } plhs[0] = mxCreateDoubleMatrix(pmodel->nOut,1,mxREAL); nrfs = mxGetPr(plhs[0]); for (i=0;i<pmodel->nOut;i++) { nrfs[i] = pmodel->sub[i].numRFS; } if (pmodel == &model) lwpr_free_model(&model); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) { int ok; LWPR_ReceptiveField RF,RFT; LWPR_Model model; const double *xc; double y; if (nrhs<4) mexErrMsgTxt("Too few arguments."); create_model_from_matlab(&model,prhs[0]); xc = mxGetPr(prhs[2]); if (mxGetM(prhs[2])!=model.nIn || mxGetN(prhs[2])!=1) { lwpr_free_model(&model); mexErrMsgTxt("3rd parameter (center) does not match model dimensions.\n"); } y = mxGetScalar(prhs[3]); if (mxIsEmpty(prhs[1])) { ok = lwpr_aux_init_rf(&RF,&model,NULL,xc,y); } else { create_RF_from_matlab(&RFT,&model, prhs[1], 0); ok = lwpr_aux_init_rf(&RF,&model,&RFT,xc,y); lwpr_mem_free_rf(&RFT); } lwpr_free_model(&model); if (!ok) mexErrMsgTxt("Couldn't allocate storage for RF.\n"); plhs[0] = mxCreateStructMatrix(1,1, RF_FIELDS, RF_FIELD_NAMES); fill_matlab_from_RF(&RF,plhs[0],0); lwpr_mem_free_rf(&RF); }