static void Main(string[] args) { // get data table DataTable table = getData(); // create the MWCellArray int numRows = table.Rows.Count; int numCols = table.Columns.Count; MWCellArray cell = new MWCellArray(numRows, numCols); // one-based indices // fill it cell-by-cell for (int r = 0; r < numRows; r++) { for (int c = 0; c < numCols; c++) { // fill based on type Type t = table.Columns[c].DataType; if (t == typeof(DateTime)) { //cell[r+1,c+1] = new MWNumericArray( convertToMATLABDateNum((DateTime)table.Rows[r][c]) ); cell[r + 1, c + 1] = convertToMATLABDateNum((DateTime)table.Rows[r][c]); } else if (t == typeof(string)) { //cell[r+1,c+1] = new MWCharArray( (string)table.Rows[r][c] ); cell[r + 1, c + 1] = (string)table.Rows[r][c]; } else { //cell[r+1,c+1] = new MWNumericArray( (double)table.Rows[r][c] ); cell[r + 1, c + 1] = (double)table.Rows[r][c]; } } } // call MATLAB function CellClass obj = new CellClass(); obj.my_cell_function(cell); // Wait for user to exit application Console.ReadKey(); }