How to export a Matlab cell array to an Excel spreadsheet?
143 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Azzi Abdelmalek
2013 年 11 月 24 日
編集済み: Azzi Abdelmalek
2013 年 11 月 24 日
X=[{'A','B','C','D'};A,B,C,D]
xlswrite('X.xls',X)
4 件のコメント
Rini
2014 年 10 月 16 日
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!
その他の回答 (2 件)
Image Analyst
2013 年 11 月 24 日
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 件のコメント
Image Analyst
2013 年 11 月 24 日
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
2017 年 10 月 18 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!