怎么在MATLAB里把下面的运算结果,输出为txt或者excel文件

比如::::下面的结果,怎么输出为1列
olumns 1 through 8

-0.0002 -0.0004 -0.0006 -0.0008 -0.0010 -0.0012 -0.0013 -0.0014

Columns 9 through 16

-0.0015 -0.0016 -0.0017 -0.0017 -0.0017 -0.0017 -0.0016 -0.0015

Columns 17 through 24

-0.0014 -0.0013 -0.0012 -0.0010 -0.0008 -0.0006 -0.0004 -0.0002

Columns 25 through 32

-0.0000 0.0002 0.0004 0.0006 0.0008 0.0010 0.0012 0.0013

Columns 33 through 40

0.0014 0.0015 0.0016 0.0017 0.0017 0.0017 0.0017 0.0016

Columns 41 through 48

0.0015 0.0014 0.0013 0.0012 0.0010 0.0008 0.0006 0.0004

Columns 49 through 56

0.0002 0.0000 -0.0002 -0.0004 -0.0006 -0.0008 -0.0010 -0.0012

Columns 57 through 64

-0.0013 -0.0014 -0.0015 -0.0016 -0.0017 -0.0017 -0.0017 -0.0017

Columns 65 through 72

-0.0016 -0.0015 -0.0014 -0.0013 -0.0012 -0.0010 -0.0008 -0.0006

MATLAB有非常直接的方法可以输出到文本和Excel文件
假设以上数据保存在矩阵M里
1) xlswrite('myxls.xls',M) 输出到Excel里

2) save myfile.txt M -ascii 输出到myfile.txt文件里追问

我说的是1列啊,输出结果为一列,在excel或者txt里面

追答

将矩阵转置再输出
xlswrite('myxls.xls',M')

温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-07-11
新建一个aa.txt格式的文件在当前目录下,假设你这个变量名为a
a=1:100;
>> op=fopen('aa.txt','w');
>> for i=1:length(a)
fprintf(op,'%f\n',a(i));
end
>> fclose all
第2个回答  2013-07-11
A=[......];
XLSWRITE('c:\result.xls',A,'A1:A72')
相似回答