我目前遇上了元胞数组无法输出或无法完整输出到txt/dat文件的问题。网上有用 fprintf 和writetable两种方法,可是用fprintf的方法提示没有为‘cell’输入定义函数,可是我明明已经正确地定义了函数了!我不知道问题出在哪里,有哪位好心人给我解个惑吗:Q ?writetable的方法只的输出了C2{1}(1,1)的数据,其他的都没有输出。
fprintf 方法的代码:
filename='alterch';
fid=fopen(filename);
formatSpec=[repmat('%s ',1,3) ...
repmat('%f ',1,904)];
C = textscan(fid,formatSpec,'HeaderLines',1,'Delimiter','\t');
C2=[];
[nrows ncols]=size(C);
n=length(C{:,1});
for col=1:ncols;
j=1
for i=1:3:n;
C2{1,col}(j,1)=C{1,col}(i,1);
j=j+1;
end
end
fileid=fopen('alterch_out.dat','w');
[nrow2 ncol2]=size(C2);
T=[];
formatSpec=[repmat('%s ',1,3) ...
re