MATLAB: Can I write a cell array containing matrices into multiple cells of a Microsoft Excel file using XLSWRITE in MATLAB 7.x(R14SP2+)

cellsMATLABmultiplexlswrite

I have a cell array that contains vectors and/or matrices. I would like to write the contents of this cell array into several groups of cells on an Excel spreadsheet using a single XLSWRITE command.
For example, I create a cell array in MATLAB:
a={[1 2;3 4], [5,6,7]};
Then, I issue the following command:
xlswrite('xlsexample.xls',a);
The file 'xlsexample.xls' is created, but contains no data.

Best Answer

The ability to write cell arrays that contain matrices and strings in a single XLSWRITE command is not available. XLSWRITE works with matrices that are not contained in cell arrays, and with cell arrays that combine scalars (single numbers) and strings, but not with cell arrays that contain matrices or vectors.
To work around this issue, you can either convert your data in MATLAB to a single cell array in this format, or you can issue multiple commands to XLSWRITE, each specifying a sheet and location.
In the example shown in this problem report, you can write the data to a single spreadsheet with the following two commands:
xlswrite('xlsexample.xls',a{1},'Sheet1','A1');
xlswrite('xlsexample.xls',a{2},'Sheet1','A3');
Also, if all of the data in the cell array is numeric, of the same type, and of appropriate sizes, you may be able to convert the cell array to a matrix using the CELL2MAT function. To see the documentation on CELL2MAT, including a description of the limitations on the input cell array, type:
doc cell2mat
Related Question