将不常见的单元格数组写入Matlab中的.csv文件

时间:2013-02-13 17:24:18

标签: matlab csv

所以我正在探索这个主题的论坛,找不到回答我问题的相关帖子,所以这里就是这样。我想将一个单元格数组保存为Matlab中的.csv文件。我的单元格数组的结构如下(这是给我带来麻烦的部分)

>> mycell

mycell = 

  Columns 1 through 8

    [76x1 double]    {76x1 cell}    {76x1 cell}    [76x75 double]    [76x1 double]    [76x1 double]    {76x1 cell}    {76x1 cell}

  Columns 9 through 17

    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}    {76x1 cell}

  Column 18

    {76x1 cell}

所以我一直在尝试自己无济于事的是:

>> 
[nrows,ncols]= size(mycell);

filename = output_file;
fid = fopen(filename, 'w');

for row=1:nrows
    fprintf(fid, '%d,%s,%s,%d,%d,%d,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s\n', mycell{row,:});
end

fclose(fid);
??? Error using ==> fprintf
Function is not defined for 'cell' inputs.

非常感谢任何建议!谢谢!

1 个答案:

答案 0 :(得分:0)

单元阵列的不规则结构会使写入CSV文件变得困难。前六个索引是矩阵,而其余索引都是单元阵列。我怀疑将它们全部转换为矩阵将解决您的问题。

相关问题