Write out a cell whith characters and numbers to excel
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I create a 1 x 4 cell where:
col 1 = 23 x 20 char (i.e. dates and times)
col 2 = 23 x 1 double (data)
col 3 = 23 x 1 double (data)
col 4 = 23 x 1 double (data)
When I try to write this out to an excel file, I get the error message: Error using xlswrite (line 219) ActiveX - Element of a cell array cannot be a character matrix.
Even if I create a 1 x 4 cell where all 4 columns are type 'char' (I used num2str on the data), I receive the same message when I try to write out the cell to excel.
IdxAbsTilt = AbsTilt>50;
DateBad=datestr(Date(IdxAbsTilt));
BadDataCell{1,1} = DateBad;
BadDataCell{1,2} = num2str(Spd(IdxAbsTilt));
BadDataCell{1,3} = num2str(Dir(IdxAbsTilt));
BadDataCell{1,4} = num2str(AbsTilt(IdxAbsTilt));
xlswrite('BadData.xlsx',BadDataCell) % this does not work;
How do I write out my cell to excel?
0 个评论
采纳的回答
Guillaume
2016-1-20
编辑:Guillaume
2016-1-20
xlswrite only works with cell arrays that contain scalar numeric or string vectors. My guess is that you want end up with 23 rows in your excel spreadsheet. For that, you need to generate a 23x4 cell array:
GoodDataCell = [cellstr(datestr(Date(IdxAbsTilt))), ...
num2cell(Spd(IdxAbsTilt)), ...
num2cell(Dir(IdxAbsTilt)), ...
num2cell(AbsTilt(IdxAbsTilt))];
should do it
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!