The following code read a matrix stack to a matrix sheet and copy one of the matrix into a worksheet
void mdc(string strpath)
{
MatrixPage mp;
mp.Create("Origin", CREATE_HIDDEN);
//add matlab connector to the matrix book
mp.DoMethod("dc.Add", "MATLAB");
MatrixLayer ml = mp.Layers();
//setup the connection
ml.SetProp("dc.Source", strpath);
//set the selection path into the structure
ml.SetProp("dc.Sel", "MATLAB/Fs2Fs_EMGinterpol_optiHz_norm");
//this is to execute the actual import
ml.DoMethod("dc.import");
//you can remove the connector after import
mp.DoMethod("dc.remove");
//pick one of the matrix and transfer to a worksheet
MatrixObject mobj = ml.MatrixObjects(4);
WorksheetPage wp;
wp.Create("Origin");
Worksheet wks = wp.Layers();
matrixbase& mb = mobj.GetDataObject();
mb.CopyTo(wks, 0, 0, -1, -1, 0, 0, false, false);
}
I recommend that you play with the connector from GUI too
1. New Matrix
2. Data > Connect to File > Matlab
CP