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 faster and easier to see which values differ from zero. 回答1: 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