This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Read tab-delimited file


s = tdfread(filename,...)


tdfread displays the File Open dialog box for interactive selection of a data file, then reads data from the file. The file should have variable names separated by tabs in the first row, and data values separated by tabs in the remaining rows. tdfread creates variables in the workspace, one for each column of the file. The variable names are taken from the first row of the file. If a column of the file contains only numeric data in the second and following rows, tdfread creates a double variable. Otherwise, tdfread creates a char variable. After all values are imported, tdfread displays information about the imported values using the format of the tdfread command.

tdfread(filename) allows command line specification of the name of a file in the current folder, or the complete path name of any file, using filename.

tdfread(filename,delimiter) indicates that the character specified by delimiter separates columns in the file. Accepted values for delimiter are:

  • ' ' or 'space'

  • '\t' or 'tab'

  • ',' or 'comma'

  • ';' or 'semi'

  • '|' or 'bar'

The default delimiter is 'tab'.

s = tdfread(filename,...) returns a scalar structure s whose fields each contain a variable.


The following displays the contents of the file sat2.dat:

type sat2.dat


The following creates the variables Gender, Score, and Test from the file sat2.dat and displays the contents of the MATLAB® workspace:


Name    Size    Bytes    Class    Attributes

Gender  4x6     48       char
Score   4x1     32       double
Test    4x12    96       char

Introduced before R2006a

Was this topic helpful?