Import data from file
The Import Tool lets you preview and import data from spreadsheet files, delimited text files, and fixed-width text files. You can interactively select the data to import and reuse the script or function that the tool generates to import other similar files.
MATLAB® Toolstrip: On the Home tab, in the Variable section, click Import Data.
MATLAB command prompt: Enter
filename is a character vector specifying the
name of a text or spreadsheet file.
Import ranges of data from a tab-delimited text file and replace nonnumeric values in the file.
Drag the cursor to select the cells to import. Press Ctrl to select noncontiguous ranges.
Modify the Variable Names Row field to indicate the row you want the Import Tool to use for the variable names.
NaN replaces unimportable values in numeric
cells. However, you can change this value to any other numeric value.
Specify how to treat unimportable values on the Import
tab, in the Unimportable Cells section.
Alternatively, exclude any row that contains an unimportable cell from being imported.
Click Import Selection . The new column vectors appear in your workspace.
Import dates and numbers from a text file into a table. Specify the decimal separator for numeric values in the file and a custom format for dates.
In the Imported Data section, select
Table to import the file data into a
table variable. In this example, the third column of
data contains monetary amounts where the decimal separator is a comma. In
the Delimiters section, select Delimiter
Options. Then, under Decimal Separator,
select , (comma).
The Import Tool appropriately converts the monetary values.
Specify that a column contains date or time data by changing the data type for the column to DATE/TIME. Click more date formats.... Scroll down the list to enter a custom date format.
Click Import Selection to import the table.
On Linux® platforms, Import Tool cannot open spreadsheet files
written by the