Development Environment |
Importing Numeric Data with Text Headers
To import an ASCII data file that contains text headers, use the textread
function, specifying the headerlines
parameter. textread
accepts a set of predefined parameters that control various aspects of the conversion. (For a complete list of these parameters, see the textread
reference page.) The headerlines
parameter lets you specify the number of lines at the head of the file that textread
should ignore.
For example, the file grades.dat
contains formatted numeric data with a one-line text header.
To import this data, use this command:
[grade1 grade2 grade3] = textread('grades.dat','%f %f %f',... 'headerlines',1) grade1 = 78.8000 99.5000 89.5000 grade2 = 55.9000 66.8000 77.0000 grade3 = 45.9000 78.0000 56.7000
Importing Delimited ASCII Data Files | Importing Mixed Alphabetic and Numeric Data |