2
votes


I have many files with text:

LON   LAT   DEPTH  C
    9.0928    9.0928     91.       .22215180E+00

I using dlmread function:

data = dlmread(fname, ' ', 1, 0);

But I get error:

Badly formed format string.

How can I ignore header text and get counts via dlmread in this case?


Thank you in advance

1
I works for me (R2015b). But use data = dlmread(fname, '', 1, 0) to treat multiple spaces as a single delimiter - Luis Mendo

1 Answers

1
votes

The function dlmread is suited to read files with numeric data.

To read an input file with one or more header lines, you can use importdata as follows:

% Define the delimiter
delim=' ';
% Define the number of header lines
header_line=1;
% Read the inout file
C=importdata('in_.txt',delim,header_line)

The content of the input file is stored in the "C" struct; in particular, the "numeric data" are stored in the "data" field.

Hope this helps.