1

因此,我正在探索该主题的论坛,但找不到回答我的问题的相关帖子,所以就到这里。我想从 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.

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

4

1 回答 1

0

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

于 2013-02-13T17:46:54.730 回答