【发布时间】:2016-01-19 19:28:00
【问题描述】:
我有一个 39x4 的单元格:
'ID' 'x' 'y' 'z'
459 34 -49 -20
464 36 -38 -22
639 40 -47 -27
719 35 -52 -20
725 42 -45 -18
727 46 -47 -26
...
我想将所有这些都写入一个文本文件。我尝试了以下方法:
fileID = fopen('test2.txt','w');
formatSpec='%s %d %d %d';
fprintf(fileID,formatSpec,P{:});
fclose(fileID);
但是,如果我这样做,我会收到 fprintf 没有为“单元格”输入定义的错误。我已经看到了几个像这样的例子,关于如何print a cell array as .txt in Matlab 这个例子是关于如何write cell array of combined string and numerical input into text file,但如果没有一些笨拙的修改,它们似乎不太适合。
有人可以帮忙吗?
【问题讨论】: