文本文件
分隔文本文件和格式化文本文件
读写分隔文本文件和格式化文本文件(包括 .csv
和 .txt
文件)中的数值数据和非数值数据。
App
导入工具 | 从文件导入数据 |
实时编辑器任务
导入数据 | Import data from a file in the Live Editor (自 R2023a 起) |
函数
对象
tabularTextDatastore | 表格文本文件的数据存储 |
主题
从文本文件中读取表格数据
- 导入文本文件
MATLAB® 能够读写分隔文本文件和格式化文本文件(包括.csv
和.txt
文件)中的数值数据和非数值数据。文本文件通常包含数值和文本数据以及变量名称和行名称的混合。您可以在 MATLAB 中将这些数据表示为表、时间表、矩阵、元胞数组或字符串数组。 - 使用导入工具读取文本文件数据
预览文本文件或剪贴板中的表格数据,并使用导入工具选择要导入的数据。 - Import Data from Text File to Table
The best way to represent tabular data from text files in MATLAB is in a table since tables can store heterogeneous (a mix of numeric and text) data, as well as variable and row names. - Control How MATLAB Imports Your Data
If you want to control the import process beyond the options provided by thereadtable
function, such as defining how to handle missing data or errors, then create an import options object before importing the data. - 将文本文件中的混合数据块导入表或元胞数组
将文本文件中的块格式表格数据导入表或元胞数组中。 - 将文本文件中的数值数据导入矩阵
除了使用readtable
将文本文件中的数值表格数据作为表导入之外,您还可以将这些数据作为矩阵导入到 MATLAB 工作区。 - 从文本文件导入数值数据块
将文本文件中的任意块格式数值数据读入元胞数组中。 - 读取和分析大型表格文本文件
以下示例说明如何为包含表格数据的大型文本文件创建数据存储,然后采用逐个块或逐个文件的方式读取和处理数据。 - 从文本文件中导入日期时间
从列向表格数据中导入格式化的日期时间(例如'01/01/01'
或'12:30:45'
)。 - Read Collection or Sequence of Text Files
Read and manage data from a collection of text files.
将表格数据写入文本文件
- 将数据写入文本文件
将表、元胞数组或数值数组中包含的表格数据从 MATLAB 工作区导出到文本文件。