Writing headings AND data with the xlswrite function

조회 수: 2 (최근 30일)
Mauro Baldi
Mauro Baldi 2015년 5월 30일
댓글: dpb 2015년 5월 31일
I have a cell array named NomiDopo containing the names of the columns of my Excel output file and the data (of double) stored in matrix DataSet. If I write
A = {NomiDopo; DataSet}; xlswrite('Guida_1_dopo.xlsx', A);
then the output file does not contain anything. How can I write both the name of the columns and the data in the output file at the same time? Thank you!

답변 (1개)

dpb
dpb 2015년 5월 30일
Per the doc for xlswrite, the information written must be "... specified as a two-dimensional numeric or character array, or, if each cell contains a single element, a cell array. If A is a cell array containing something other than a scalar numeric or a string, then xlswrite silently leaves the corresponding cell in the spreadsheet empty."
Your cell array contains an array as a cell element, not an element of the array per cell.
  댓글 수: 2
Mauro Baldi
Mauro Baldi 2015년 5월 31일
Thank you for your kind answer. Does this mean I have to convert the Dataset (numeric) matrix into a cell matrix and concatenate it to the heading which is already a cell array? If so, how could I convert the numeric matrix Dataset into a cell matrix? Thank you!
dpb
dpb 2015년 5월 31일
I'd just make two calls, myself...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by