How to export a Matlab cell array to an Excel spreadsheet?
128 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Rinu
le 24 Nov 2013
Réponse apportée : João Araújo
le 18 Oct 2017
I have a cell array X={'A','B','C','D',A,B,C,D} where A,B,C and D are column vectors of equal size. I intended to create a spreadsheet by: >>xlswrite('X.xls',X) but I didnt get the values of the vectors in my spreadsheet. Maybe I didn't create the cell array properly (when I display the cell array, I get: >> X X =
'A' 'B' 'C' 'D'
{241x1 cell} {241x1 cell} {241x1 cell} {241x1 cell}
Can anyone provide any suggestions? Thanks.
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 24 Nov 2013
Modifié(e) : Azzi Abdelmalek
le 24 Nov 2013
X=[{'A','B','C','D'};A,B,C,D]
xlswrite('X.xls',X)
4 commentaires
Rini
le 16 Oct 2014
Is there a way to iteratively write a large cell array to excel file? I have an cell array of 20000 by 1 and in each cell there are varied number of strings. I tried xlswrite (filename,A) but it did nothing. Thanks!
Plus de réponses (2)
Image Analyst
le 24 Nov 2013
It looks like A, B, C, and D are actually cell arrays, not regular numerical arrays. How did you create A, B, C, and D? Did you put braces around them when you created them? If so, you don't want to do that.
A = rand(5); % OK. A is a double array.
A = {rand(5)}; % Not okay - A is now a cell.
3 commentaires
Image Analyst
le 24 Nov 2013
Yeah you're right. Now that I think about it, it can write out a numerical array, but if you're going to combine them (strings plus numbers) then you need to have one big cell array where each cell is just one number (element) from the numerical array, not the whole array. So you'd need to do
ca = cell(25, 4);
ca{1,1} = 'A';
ca{1,2} = 'B';
ca{1,3} = 'C';
ca{,14} = 'D';
for k = 2:25
ca{1, k} = A(k-1);
ca{2, k} = B(k-1);
ca{3, k} = C(k-1);
ca{4, k} = D(k-1);
end
João Araújo
le 18 Oct 2017
I have a follow up question. I'm looking to organize some data, and I have a cell array with some names. The cells aren't necessarily the same size, since I can have 5 names in one cell and 12 in the next. I have a total of 1783 cells, so I'm looking for an automated way to solve this issue. How can I export this cell array to an excel spreadsheet?
0 commentaires
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!