开发者

How can I control the formatting when saving a matrix to a file?

I save a matrix to a file like this:

save(filepath, 'mtrx', '-ascii');

Is there a way to tell MATLAB to write 0 instead of 0.0000000e+000 values? It would be nice because it would be fa开发者_运维百科ster and easier to see which values differ from zero.


I suggest using DLMWRITE instead of SAVE since you're dealing with ASCII files. It will give you more control over the formatting. For example, you could create an output file delimited by spaces with a field width of 10 and 6 digits after the decimal point (see more about format specifiers here):

dlmwrite(filepath,mtrx,'delimiter',' ','precision','%10.6g');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜