Write out a cell whith characters and numbers to excel
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jenny
el 20 de En. de 2016
Respondida: Chetan Rawal
el 22 de En. de 2016
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 comentarios
Respuesta aceptada
Guillaume
el 20 de En. de 2016
Editada: Guillaume
el 20 de En. de 2016
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
Más respuestas (1)
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!