| Statistics Toolbox™ | ![]() |
tdfread
tdfread(filename)
tdfread(filename,delimiter)
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 directory, or the complete path name of any file, using the string 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 Test,Gender,Score Verbal,Male,470 Verbal,Female,530 Quantitative,Male,520 Quantitative,Female,480
The following creates the variables Gender, Score, and Test from the file sat2.dat and displays the contents of the MATLAB® workspace:
tdfread('sat2.dat',',')
Name Size Bytes Class Attributes
Gender 4x6 48 char
Score 4x1 32 double
Test 4x12 96 char![]() | tcdf | test | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |