- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

# mexlog.h

    00001 #include "stat/loggers.h"
    00002
    00003 namespace bdm{
    00004 int mxReplaceFieldNM(mxArray *X,const char * fname,mxArray *X1)
    00005 {
    00006         mxArray *Old;
    00007         int i;
    00008
    00009         if((i=mxGetFieldNumber(X,fname))==-1)
    00010         {
    00011                 if((i=mxAddField(X,fname))==-1) return i;
    00012
    00013         }
    00014
    00015         Old=mxGetFieldByNumber(X,0,i);
    00016         if(Old)mxDestroyArray(Old);
    00017         mxSetFieldByNumber(X,0,i,X1);
    00018         return i;
    00019
    00020 };
    00021
    00022 class mexlog : public memlog {
    00023         public:
    00025         mexlog(): memlog(0,"mx"){};
    00027         mxArray* toCell(){
    00028                 mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL);
    00029
    00030                 //copied from itsave
    00031                 int i;
    00032                 string vec_name="";
    00033                 int istart, iend;
    00034
    00035                 mat M; //temporary matrix
    00036                 for ( i=0; i<entries.length();i++ ) {
    00037                         istart=0;
    00038                         for (int j=0; j<entries(i).length(); j++){ // same for as in add!!!
    00039                                 vec_name = names(i) + entries(i).name(j);
    00040                                 iend=istart+entries(i).size(j)-1;
    00041                                 M=vectors(i).get_cols(istart,iend);
    00042                                 istart=iend+1;
    00043                                 // copy the selection to mx
    00044                                 mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL);
    00045                                 mat2mxArray(M,fld);
    00046                                 mxReplaceFieldNM(tmp, vec_name.c_str(), fld);
    00047                         }
    00048                 }
    00049                 return tmp;
    00050         }
    00051         void from_setting (const Setting &root){
    00052           maxlen=root["maxlen"];
    00053         }
    00054 };
    00055 UIREGISTER(mexlog);
    00056 }