Dlmwrite: writes a matrix to a file separated by delimiters.
When saving an integer to a file using save to save it as an ASCII file, it is often the data in the file is in real format (there are decimal points, and a lot of the following 0, it looks very inconvenient ). Therefore, we can use this dlmwrite command to save such data.
Usage:
Dlmwrite ('filename', m)
Use the default separator "," To write matrix m to the filename of the text file;
Dlmwrite ('filename', M, 'd ')
Use the separator d to split data. "\ t" indicates tab segmentation. "," indicates the default delimiter;
Dlmwrite ('filename', M, 'D', R, c)
Starting from row R and column C of matrix m, as the upper left corner of the matrix block to be written, data is written into the file using D.
Other usage:
Dlmwrite ('filename', M, 'b1 B1 ', value1, 'b2 B2', value2 ,...)
Dlmwrite ('filename', M, '-append ')
Dlmwrite ('filename', M, '-append', attribute-Value List)
For example:
A = [1 2 3; 4 5 6; 7 8 9];
Dlmwrite('test.txt ', );
The content in test.txt is:
1, 2, 3
4, 5, 6
7, 8, 9
Use save
A = [1 2 3; 4 5 6; 7 8 9];
Save 'tst.txt 'a-ASCII;
The content in the text file is:
1.0000000e + 000 2.0000000e + 000 3.0000000e + 000
4.0000000e + 000 5.0000000e + 000 6.0000000e + 000
7.0000000e + 000 8.0000000e + 000 9.0000000e + 000
MATLAB saves data as text files