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

- File List
- File Members

# mexlog.h

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