From Evernote: |
Matlab 变量保存成 ASCII 文件Clipped from: http://www.mathworks.cn/cn/help/matlab/ref/dlmwrite.html |
可以使用如下几个命令
save
dlmwrite
fprintf
save 不能指定格式
推荐使用 dlmwrite
参数如下
Attribute | Value |
---|---|
delimiter | Delimiter string to be used in separating matrix elements |
newline | Character(s) to use in terminating each line (see table below) |
roffset | Offset, in rows, from the top of the destination file to where matrix data is to be written. Offset is zero based. |
coffset | Offset, in columns, from the left side of the destination file to where matrix data is to be written. Offset is zero based. |
precision | Numeric precision to use in writing data to the file. Specify the number of significant digits or a C-style format string starting in %, such as '%10.5f'. |
x = 0:.1:1; A = [x; exp(x)]; fileID = fopen('exp.txt','w'); fprintf(fileID,'%6s %12s\n','x','exp(x)'); fprintf(fileID,'%6.2f %12.8f\n',A); fclose(fileID);
0 comments:
Post a Comment