dlmwrite
Writes the matrix to a file separated by delimiters.
When saving an integer into a file and saving it as an ascii file, the file is often full of data in real format (there are decimal points and many zeros behind it, which is inconvenient to view). So to save this kind of data, we can use this dlmwrite command.
How to use:
Dlmwrite ('file name', m)
Use the default delimiter ","to write the matrix m into the text file filename.
Dlmwrite ('file name', m,' d')
Use delimiter d to divide data, "\t" means tab division, and ""is 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 divided into files by D..
Other uses include:
Dlmwrite ('file name', m,' attribute 1', value 1,' attribute 2', value 2, ...)
dlmwrite('filename ',M,'-append ')
Dlmwrite('filename', m,' -append', attribute value list)
For example: a = [12 3; 4 5 6; 7 8 9];
dlmwrite('test.txt ',a);
The content in test.txt is:
1,2,3
4,5,6
7,8,9
And use save.
a =[ 1 2 3; 4 5 6; 7 8 9];
Save' tst.txt' a-ascii;
The contents in the text file are as follows:
1.0000000 e+000 2.0000000 e+000 3.0000000 e+000
4.00000000 e+000 5.0000000 e+000 6.0000000 e+000
7.00000000 e+000 8.0000000 e+000 9.0000000 e+000