写单元阵列到文本文件作为两栏数据 [英] write cell array into text file as two column data
本文介绍了写单元阵列到文本文件作为两栏数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我这是为电池阵列存储两个不同的变量。我尝试打开文本文件,并存储这些变量作为两列的阵列。下面是我的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
这篇关于写单元阵列到文本文件作为两栏数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文