Write out a cell whith characters and numbers to excel
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jenny
le 20 Jan 2016
Réponse apportée : Chetan Rawal
le 22 Jan 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 commentaires
Réponse acceptée
Guillaume
le 20 Jan 2016
Modifié(e) : Guillaume
le 20 Jan 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
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Spreadsheets dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!