Index: /library/mex/buildmex.sh
===================================================================
--- /library/mex/buildmex.sh (revision 319)
+++ /library/mex/buildmex.sh (revision 327)
@@ -1,4 +1,12 @@
 #!/bin/sh
-mex -l itpp -l bdm -I/home/smidl/soft/matlab/matlab/extern/include -I/home/smidl/work/git/mixpp/bdm  -L ../../bdm/ -L ../../system/linux/libs/ $1 
+
+#MATLAB_PATH=/usr/local/matlab7/
+#BDM_PATH=../../bdm
+
+MATLAB_PATH=/home/smidl/soft/matlab/matlab/
+BDM_PATH=/home/smidl/work/git/mixpp/bdm
+
+#mex -g -l itpp -l bdm -I$MATLAB_PATH/extern/include -I$BDM_PATH  -L ../../bdm/ -L ../../linux/libs/ $1 
+mex -l itpp -l bdm -I$MATLAB_PATH/extern/include -I$BDM_PATH  -L ../../bdm/ -L ../../linux/libs/ $1 
 #mxestimator.cpp
 #mex -l bdm -I ../../bdm/ -I /home/smidl/soft/matlab/matlab/extern/include -L ../../bdm/ linefit2.cpp
Index: /library/mex/mexparse.h
===================================================================
--- /library/mex/mexparse.h (revision 327)
+++ /library/mex/mexparse.h (revision 327)
@@ -0,0 +1,93 @@
+#include "../../bdm/libconfig/libconfig.h++"
+#include <itpp/itmex.h>
+#include <stdlib.h>
+
+using namespace std;
+using namespace libconfig;
+
+class UImxArray : public Config {
+public:
+	UImxArray(const mxArray *mxarray) : Config() {
+		Setting & setting = this->getRoot(); //setting is a group
+		if (!mxIsStruct(mxarray)) { mexErrMsgTxt("Given mxArray is not a struct."); };
+		//mexCallMATLAB(0, NULL, 1, (mxArray **) &mxarray, "dump");
+		fillGroup(setting, mxarray);
+	}
+
+private:
+	void storeNumeric(Setting &setting, const mxArray *value, string key = "") {
+		//TODO: integer matrices
+		if (!mxIsNumeric(value)) { mexErrMsgTxt("Given mxArray is not numeric."); };
+		mat val = mxArray2mat(value);
+		if ((val.rows() == 1) && (val.cols() == 1)) {
+			Setting &child = (key=="") ? setting.add(Setting::TypeFloat)
+			                           : setting.add(key, Setting::TypeFloat);
+			child = val(0,0);
+		} else {
+			Setting &child = (key=="") ? setting.add(Setting::TypeGroup)
+			                           : setting.add(key, Setting::TypeGroup);
+			Setting &elements = child.add("elements", Setting::TypeArray);
+			Setting &cols = child.add("cols", Setting::TypeInt);
+			cols = val.cols();
+			for (int i=0; i<val.rows(); i++) {
+				for (int j=0; j<val.cols(); j++) {
+					Setting &el = elements.add(Setting::TypeFloat);
+					el = val(i,j);
+				}
+			}
+		}
+	}
+
+	void fillGroup(Setting &setting, const mxArray *mxarray) {
+		if (!mxIsStruct(mxarray)) { mexErrMsgTxt("Given mxArray is not a struct."); };
+		for(int i=0; i < mxGetNumberOfFields(mxarray); i++) {
+			const char *key = mxGetFieldNameByNumber(mxarray, i);
+			mxArray *value = mxGetField(mxarray, 0, key);
+			if (mxIsChar(value)) {
+				Setting &child = setting.add(key, Setting::TypeString);
+				child = mxArray2string(value);
+			}
+			if (mxIsLogical(value)) {
+				Setting &child = setting.add(key, Setting::TypeBoolean);
+				child = (bool) mxArray2bin(value);
+			}
+			if (mxIsStruct(value)) {
+				Setting &child = setting.add(key, Setting::TypeGroup);
+				fillGroup(child, value);
+			}
+			if (mxIsCell(value)) {
+				Setting &child = setting.add(key, Setting::TypeList);
+				fillList(child, value);
+			}
+			if (mxIsNumeric(value)) {
+				storeNumeric(setting, value, (string)key);
+			}
+		}
+	}
+	
+	void fillList(Setting &setting, const mxArray *mxarray) {
+		if (!mxIsCell(mxarray)) { mexErrMsgTxt("Given mxArray is not a cell."); };
+		for(int i=0; i < mxGetNumberOfElements(mxarray); i++) {
+			mxArray *value = mxGetCell(mxarray, i);
+			if (mxIsChar(value)) {
+				Setting &child = setting.add(Setting::TypeString);
+				child = mxArray2string(value);
+			}
+			if (mxIsLogical(value)) {
+				Setting &child = setting.add(Setting::TypeBoolean);
+				child = (bool) mxArray2bin(value);
+			}
+			if (mxIsStruct(value)) {
+				Setting &child = setting.add(Setting::TypeGroup);
+				fillGroup(child, value);
+			}
+			if (mxIsCell(value)) {
+				Setting &child = setting.add(Setting::TypeList);
+				fillList(child, value);
+			}
+			if (mxIsNumeric(value)) {
+				storeNumeric(setting, value);
+			}
+		}
+	}
+};
