Development Environment | ![]() ![]() |
Importing Delimited ASCII Data Files
If your data file uses a character other than a space as a delimiter, you have a choice of several import functions you can use. (See Table 6-4 for a complete list.) The simplest to use is the dlmread
function.
For example, consider a file named ph.dat
whose contents are separated by semicolons.
7.2;8.5;6.2;6.6 5.4;9.2;8.1;7.2
To read the entire contents of this file into an array named A
, enter
A = dlmread('ph.dat', ';');
You specify the delimiter used in the data file as the second argument to dlmread
. Note that, even though the last items in each row are not followed by a delimiter, dlmread
can still process the file correctly. dlmread
ignores space characters between data elements. So, the preceding dlmread
command works even if the contents of ph.dat
are
7.2; 8.5; 6.2;6.6 5.4; 9.2 ;8.1;7.2
![]() | Importing Numeric Text Data | Importing Numeric Data with Text Headers | ![]() |