我这是为电池阵列存储两个不同的变量。我尝试打开文本文件,并存储这些变量作为两列的阵列。下面是我的code,我用\吨至单独的X和Y的数据,但在输出文件中,x数据被写入第一其后是Y数据。我怎样才能获得在文本文件中的两个列阵列?
I have two different variables which are stored as cell arrays. I try to open text file and store these variables as two column arrays. Below is my code, i used \t to seperate x and y data, but in the output file, the x data is written first which is followed by the y data. How can I obtain two column array in the text file?
for j=1:size(data1,2)
file1=['dir\' file(j,1).name];
f1{j}=fopen(file1,'a+')
fprintf(f1{j},'%7.3f\t%20.10f\n',x{1,j}',y{1,j});
fclose(f1{j});
end
在此先感谢!
Thanks in advance!
您可以使用 dlmwrite
,以及完成这一数值数据:
You can use dlmwrite
as well to accomplish this for numeric data:
x = [1;2;3]; y = [4;5;6]; % two column vectors
dlmwrite('foo.dat',{x,y},'Delimiter','\t')
这产生的输出:
1 4
2 5
3 6