I have got a cell array Ystg of size 219*1 and i want to write it into a text file .
我想这代码,但不工作如何将单元格数组或矩阵的内容写入文本文件?
C = Ystg.';
fid = fopen('file.dlm', 'wt');
fprintf(fid, '"%s"\t"%s"\t"%d"\t"%s"\t\n', C{:});
fclose(fid);`
I have got a cell array Ystg of size 219*1 and i want to write it into a text file .
我想这代码,但不工作如何将单元格数组或矩阵的内容写入文本文件?
C = Ystg.';
fid = fopen('file.dlm', 'wt');
fprintf(fid, '"%s"\t"%s"\t"%d"\t"%s"\t\n', C{:});
fclose(fid);`
这应该为你工作:
C = Ystg;
fid = fopen('file.dlm', 'wt');
for i=1:219
fprintf(fid, '"%s"\t"%s"\t"%d"\t"%s"\t\n', C{i}{:});
end
fclose(fid);
感谢bro很好的工作,但我需要它作为.txt是否可以将.dlm更改为.txt? –
@ F.caren是的,你可以使用txt文件 –
@达仁山最后一个问题我想合并前TCGA A6 2677的3个单元,变成这样TCGA -A6-2677,你有一个想法如何做到这一点? –
http://stackoverflow.com/questions/10369077/如何写入多个单元格到文本文件?rq = 1 –
http://stackoverflow.com/questions/27708871/write-a-cell-array-in-text-file-using- matlab?rq = 1 –
冷杉st谷歌命中 - [MATLAB示例:导出单元格数组到文本文件](https://www.mathworks.com/examples/matlab/mw/matlab-ex07445498-export-cell-array-to-text-file) – Steve