| 17 | #ifdef MEX |
| 18 | #include <itpp/itmex.h> |
| 19 | #include <mex/mex_BM.h> |
| 20 | #include <mex/mex_logger.h> |
| 21 | #include <mex/mex_datasource.h> |
| 22 | #include <mex/mex_function.h> |
| 23 | |
| 24 | void mexFunction ( int n_output, mxArray *output[], int n_input, const mxArray *input[] ) { |
| 25 | // Check the number of inputs and output arguments |
| 26 | if ( n_input<2 ) mexErrMsgTxt ( "Usage:\n" |
| 27 | "[Res,estimators,Res2]=estimator(system, estimators, experiment, logger)\n" |
| 28 | " system = struct('class','datasource',...); % Estimated system\n" |
| 29 | " estimators = {struct('class','estimator',...), % Estimators\n" |
| 30 | " struct('class','estimator',...),...} \n" |
| 31 | " === optional ===" |
| 32 | " experiment = struct('ndat',10); % number of data in experiment, full length of finite datasources, 10 otherwise \n" |
| 33 | " logger = struct('class','mexlogger'); % How to store results, default=mexlog, i.e. matlab structure\n\n" |
| 34 | "Output:\n" |
| 35 | " Res Matlab structure with logged results, \n" |
| 36 | " estimators Array of estimators updated with data \n" |
| 37 | " Res2 When logfull log_level is on, this structure is filled with structures of posterior densities\n\n" |
| 38 | "see documentation of classes datasource, BM, and mexlogger and their offsprings in BDM." ); |
| 39 | |
| 40 | RV::clear_all(); |
| 41 | //CONFIG |
| 42 | UImxArray F; |
| 43 | try { |
| 44 | F.addGroup ( input[0],"system" ); |
| 45 | F.addList ( input[1],"estimators" ); |
| 46 | if ( n_input>2 ) { |
| 47 | F.addGroup ( input[2],"experiment" ); |
| 48 | } |
| 49 | if ( n_input>3 ) { |
| 50 | F.addGroup ( input[3],"logger" ); |
| 51 | } |
| 52 | } catch ( SettingException e ) { |
| 53 | it_error ( "error: "+string ( e.getPath() ) ); |
| 54 | } |
| 55 | |
| 56 | //DBG |
| 57 | F.writeFile ( "pmsm_estim.cfg" ); |
| 58 | |
| 59 | #else |
| 121 | #ifdef MEX |
| 122 | mexlog* mL=dynamic_cast<mexlog*> ( L.get() ); |
| 123 | |
| 124 | if ( mL ) { // user wants output!! |
| 125 | if ( n_output<1 ) mexErrMsgTxt ( "Wrong number of output variables!" ); |
| 126 | output[0] = mL->toCell(); |
| 127 | if (n_output>1){ // write estimators |
| 128 | UImxArray Ests; |
| 129 | UI::save(Es, Ests,"estimators"); |
| 130 | output[1]=UImxArray::create_mxArray(Ests); |
| 131 | } |
| 132 | if (n_output>2) { |
| 133 | mL->_setting_conf().setAutoConvert(true); |
| 134 | output[2]= UImxArray::create_mxArray(mL->_setting_conf().getRoot()); |
| 135 | } |
| 136 | } |
| 137 | #endif |