Using xlswrite with cell array containing strings and numbers

조회 수: 2 (최근 30일)
Nikolay Rodionov
Nikolay Rodionov 2012년 10월 8일
Hi all,
How could I use xlswrite to write my (n x 3) cell array into an excel spreadsheet? Xlswrite is only compatible with arrays, and at face value converting cells to arrays doesn't seem to difficult. However, my major problem is that my string values have different lengths, which will create a dimensional error if I try to move all of data into one large array.
My data looks something like this:
[5] ['fadfafdas'] ['safdafas']
[24] ['dfd'] ['dds'] ...
Where string-cells in the same row are of equal lengths. Any ideas of how I can write this data into an excel file?
Thanks!

답변 (2개)

Andrei Bobrov
Andrei Bobrov 2012년 10월 8일
A = {[5] ['fadfafdas'] ['safdafas']
[24] ['dfd'] ['dds']}
xlswrite('yourxlsfile.xlsx',A)

Nikolay Rodionov
Nikolay Rodionov 2012년 10월 8일
Maybe that works on the PC version, I am running the mac student version of Matlab. I get his error code when I try to run your script:
Warning: Could not start Excel server for export. XLSWRITE will attempt to write file in CSV format. > In xlswrite at 175 Error using xlswrite (line 188) An error occurred on data export in CSV format.
Caused by: Error using dlmwrite (line 118) The input cell array cannot be converted to a matrix.

카테고리

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