Esempio n. 1
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_ReceptiveField RF;
   LWPR_Model model;
   const mxArray *ar;
  
   const double *x;
   double y,w,ymz;
   double *xmz;
   
   if (nrhs<4) mexErrMsgTxt("Too few arguments.");
   
   ar = mxGetField(prhs[0],0,"U");
   if (ar==NULL) mexErrMsgTxt("RF does not contain element 'U'.");
     
   model.nIn = mxGetM(ar);   
   model.nInStore = (model.nIn&1) ? (model.nIn+1) : model.nIn;
   
   create_RF_from_matlab(&RF, &model, prhs[0], 0);
   if (mxGetM(prhs[1])!=model.nIn) mexErrMsgTxt("Second parameter has bad dimensions.");
   x = mxGetPr(prhs[1]);   
   y = mxGetScalar(prhs[2]);
   w = mxGetScalar(prhs[3]);
   
   plhs[0] = mxCreateStructMatrix(1,1, RF_FIELDS, RF_FIELD_NAMES);
   plhs[1] = mxCreateDoubleMatrix(model.nIn,1,mxREAL);   
   xmz = mxGetPr(plhs[1]);
   
   ymz = lwpr_aux_update_means(&RF, x, y, w, xmz);
   
   plhs[2] = mxCreateDoubleScalar(ymz);   

   fill_matlab_from_RF(&RF,plhs[0],0); 

   lwpr_mem_free_rf(&RF);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs,const mxArray *prhs[]) {
   LWPR_ReceptiveField RF;
   LWPR_Model model;
      
   if (nrhs<2) mexErrMsgTxt("Too few arguments.");
   
   model_consts_from_matlab(&model,prhs[0]);
   create_RF_from_matlab(&RF, &model, prhs[1], 0);
      
   lwpr_aux_check_add_projection(&RF);

   plhs[0] = mxCreateStructMatrix(1,1, RF_FIELDS, RF_FIELD_NAMES);
   fill_matlab_from_RF(&RF,plhs[0],0); 
   
   lwpr_mem_free_rf(&RF);
}