Revision 265, 0.9 kB
(checked in by smidl, 16 years ago)
|
UI in matlab
|
Line | |
---|
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 |
---|
24 | mexlog(int maxlen): memlog(maxlen){}; |
---|
25 | //! |
---|
26 | mxArray* toCell(){ |
---|
27 | mxArray* tmp = mxCreateStructMatrix(1,1,0,NULL); |
---|
28 | |
---|
29 | //copy vectors to mxStruct |
---|
30 | for (int i=0; i<names.length();i++){ |
---|
31 | mat& M=vectors(i); |
---|
32 | mxArray* fld=mxCreateDoubleMatrix(M.rows(), M.cols(), mxREAL); |
---|
33 | mat2mxArray(M,fld); |
---|
34 | mxReplaceFieldNM(tmp, names(i).c_str(), fld); |
---|
35 | } |
---|
36 | return tmp; |
---|
37 | } |
---|
38 | }; |
---|
39 | |
---|
40 | class UImexlog: public UIbuilder{ |
---|
41 | public: |
---|
42 | UImexlog():UIbuilder("mexlog"){}; |
---|
43 | bdmroot* build(Setting &S) const{ |
---|
44 | return new mexlog(S["maxlen"]); |
---|
45 | }; |
---|
46 | }; |
---|
47 | UIREGISTER(UImexlog); |
---|