Choose an import method based on the format of your data and the desired data type in the MATLAB® workspace. Import text files interactively or programmatically.
To import data interactively, use the Import Tool. You can generate code to repeat the
operation on multiple similar files. The Import Tool supports text files, including
those with the extensions
.dlm. These text files can be nonrectangular and can have row and
column headers, as shown in the following figure. Data in these files can be a
combination of numeric and nonnumeric text, and can be delimited by one or more
To import data from text files programmatically, use an import function. Most of the import functions for text files require that each row of data has the same number of columns, and they allow you to specify a range of data to import.
Import text files in one of these ways.
For Examples, See...
Import a file or range of data to column vectors, a matrix, a cell array, or a table. You can generate code to repeat the operation on multiple similar files.
Import column-oriented data into a table.
Import data with additional control. For example, select the variables to import or handle rows with missing or error-causing data.
Import one or more column-oriented text files. Each file can be very large and does not need to fit in memory.
Import a nonrectangular or arbitrarily formatted text file to a cell array.
Import a file or range of comma-separated numeric data to a matrix.
Import a file or a range of numeric data separated by any single delimiter to a matrix.
For information on importing files with more complex formats, see Import Text Data Files with Low-Level I/O.