How to export a Matlab cell array to an Excel spreadsheet?
123 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Azzi Abdelmalek
il 24 Nov 2013
Modificato: Azzi Abdelmalek
il 24 Nov 2013
X=[{'A','B','C','D'};A,B,C,D]
xlswrite('X.xls',X)
4 Commenti
Rini
il 16 Ott 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!
Più risposte (2)
Image Analyst
il 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 Commenti
Image Analyst
il 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
il 18 Ott 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 Commenti
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!