[293] | 1 | #include "../bdm/stat/loggers_ui.h" |
---|
| 2 | |
---|
| 3 | int mxReplaceFieldNM(mxArray *X,const char * fname,mxArray *X1) |
---|
| 4 | { |
---|
| 5 | mxArray *Old; |
---|
| 6 | int i; |
---|
| 7 | |
---|
| 8 | if((i=mxGetFieldNumber(X,fname))==-1) |
---|
| 9 | { |
---|
| 10 | if((i=mxAddField(X,fname))==-1) return i; |
---|
| 11 | |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | Old=mxGetFieldByNumber(X,0,i); |
---|
| 15 | if(Old)mxDestroyArray(Old); |
---|
| 16 | mxSetFieldByNumber(X,0,i,X1); |
---|
| 17 | return i; |
---|
| 18 | |
---|
| 19 | }; |
---|
| 20 | |
---|
| 21 | class mexlog : public memlog{ |
---|
| 22 | public: |
---|
| 23 | //! constructor |
---|
[347] | 24 | mexlog(int maxlen): memlog(maxlen,"mx"){}; |
---|
[293] | 25 | //! |
---|
| 26 | mxArray* toCell(){ |
---|
| 27 | mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL); |
---|
| 28 | |
---|
[347] | 29 | //copied from itsave |
---|
| 30 | int i; |
---|
| 31 | string vec_name=""; |
---|
| 32 | int istart, iend; |
---|
| 33 | |
---|
| 34 | mat M; //temporary matrix |
---|
| 35 | for ( i=0; i<entries.length();i++ ) { |
---|
| 36 | istart=0; |
---|
| 37 | for (int j=0; j<entries(i).length(); j++){ // same for as in add!!! |
---|
| 38 | vec_name = names(i) + entries(i).name(j); |
---|
| 39 | iend=istart+entries(i).size(j)-1; |
---|
| 40 | M=vectors(i).get_cols(istart,iend); |
---|
| 41 | istart=iend+1; |
---|
| 42 | // copy the selection to mx |
---|
| 43 | mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); |
---|
| 44 | mat2mxArray(M,fld); |
---|
| 45 | mxReplaceFieldNM(tmp, vec_name.c_str(), fld); |
---|
| 46 | } |
---|
[293] | 47 | } |
---|
| 48 | return tmp; |
---|
| 49 | } |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | class UImexlog: public UIbuilder{ |
---|
| 53 | public: |
---|
| 54 | UImexlog():UIbuilder("mexlog"){}; |
---|
| 55 | bdmroot* build(Setting &S) const{ |
---|
| 56 | return new mexlog(S["maxlen"]); |
---|
| 57 | }; |
---|
| 58 | }; |
---|
[342] | 59 | UIREGISTER(UImexlog); |
---|