我有一个嵌套单元格数组,其中每个单元格有三列,但行数不同。我需要将值导出到excel,同时保持列不变,但使用writecell时出现错误“不支持嵌套单元格数组”。如何将值导出到excel?下面是一个简单的例子:
A1 = {1,1,1}; A2 = {2,2,2;2,2,2}; A3 = {3,3,3;3,3,3;3,3,3}; A = {A1, A2, A3}; writecell(A, 'mydata.xlsx');
au9on6nz1#
A1 = {1,1,1}; A2 = {2,2,2;2,2,2}; A3 = {3,3,3;3,3,3;3,3,3}; A = {A1, A2, A3}; [~,NoCells]=size(A); for aa=1:NoCells writecell(A{aa}, 'mydata.xlsx','WriteMode','append'); end
**edit:**正如wolfie在注解中所建议的,代码可以缩短为:
A1 = {1,1,1}; A2 = {2,2,2;2,2,2}; A3 = {3,3,3;3,3,3;3,3,3}; A = {A1, A2, A3}; for aa=1:size(A,2) writecell(A{aa}, 'mydata.xlsx','WriteMode','append');
1条答案
按热度按时间au9on6nz1#
**edit:**正如wolfie在注解中所建议的,代码可以缩短为: