Index: /issm/trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp	(revision 21880)
+++ /issm/trunk-jpl/src/wrappers/matlab/io/FetchMatlabData.cpp	(revision 21881)
@@ -996,27 +996,31 @@
 mxArray* mxGetAssignedField(const mxArray* pmxa_array,int number,const char* field){
 
-	//output
-	mxArray* mxfield=NULL;
-
-	//input
-	mxArray    *inputs[2];
-	mxArray    *pindex      = NULL;
-	const char *fnames[2];
-	mwSize      ndim        = 2;
-	mwSize      onebyone[2] = {1,1};
-
-	//We want to call the subsasgn method, and get the returned array.This ensures that if we are running 
-	//large sized problems, the data is truly loaded from disk by the model subsasgn class method.
-	inputs[0]=(mxArray*)pmxa_array; //this is the model
-
-	//create index structure used in the assignment (index.type='.' and index.subs='x' for field x for ex)
-	fnames[0] = "type";
-	fnames[1] = "subs";
-	pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
-	mxSetField( pindex, 0, "type",mxCreateString("."));
-	mxSetField( pindex, 0, "subs",mxCreateString(field));
-	inputs[1]=pindex;
-
-	mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
+	/*Output*/
+	mxArray *mxfield = NULL;
+
+	if(mxIsStruct(pmxa_array)){
+		mxfield = mxGetField(pmxa_array,number,field);
+	}
+	else{
+		/*This is an object, mxGetField returns NULL in old version of matlab (we do not have access to them)*/
+
+		/*Intermediaries*/
+		mxArray    *inputs[2];
+		mwSize      ndim        = 2;
+		mwSize      onebyone[2] = {1,1};
+
+		/*create index structure used in the assignment (index.type='.' and index.subs='x' for field x*/
+		const char *fnames[2];
+		fnames[0] = "type"; fnames[1] = "subs";
+		mxArray* pindex=mxCreateStructArray( ndim,onebyone,2,fnames);
+		mxSetField( pindex, 0, "type",mxCreateString("."));
+		mxSetField( pindex, 0, "subs",mxCreateString(field));
+		inputs[0]=(mxArray*)pmxa_array; //this is the model
+		inputs[1]=pindex;
+
+		mexCallMATLAB( 1, &mxfield, 2, (mxArray**)inputs, "subsref");
+	}
+
+	if(mxfield == NULL) _error_("Could not find field "<< field <<" in structure");
 
 	return mxfield;
