MATLAB saves data as text files

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.