Read tab-delimited file
tdfread opens the Select File to Open dialog box for interactive
selection of a data file, and reads the data from the file you select.
tdfread can read data from tab-delimited text files with
Select a file that has variable names in the first row and values separated by tabs in
the remaining rows.
tdfread creates a variable in the workspace for
each column of the file, and names each variable according to its first row value.
If a column contains only numeric data in all rows except the first, then
After importing all values,
tdfread displays information about
the imported variables, such as their size, bytes, and class.
tdfread( creates variables from the
filename, which is either the name of a file in the current
folder or the complete path name of a file.
s = tdfread(___)
s in which each field contains a variable. Specify any of
the input argument combinations in the previous syntaxes.
Create Workspace Variables from Text File
Display the contents of the
sat2.dat file. Note that the first row of the file contains the variable names.
Test,Gender,Score Verbal,Male,470 Verbal,Female,530 Quantitative,Male,520 Quantitative,Female,480
In the workspace, create the variables
Test from the columns of the file. Because commas separate the values in the file, specify
',' as the delimiter.
Name Size Bytes Class Attributes Gender 4x6 48 char Score 4x1 32 double Test 4x12 96 char
filename — Name of file to read
character vector | string scalar
Name of the file to read, specified as a character vector or string scalar.
Depending on the location of the file,
filename has one of
|Location of File
|Current folder or folder on the MATLAB® path
Specify the name of the file in
|Folder that is not the current folder or a folder on the MATLAB path
Specify the full or relative path name in
delimiter — Delimiter character
'tab' (default) |
'space' | ...
Delimiter character, specified as one of the values in this table.
Introduced before R2006a