erogol
erogol

Reputation: 13624

Reading a '.txt' data file in columns to a matrix in MATLAB

I have a file like

86999490    88641807@N00    newyork truck city night light red road street springstreet
86999495    34675390@N00    sky
86999496    97245056@N00    scarborough
86999503    97245056@N00    york
86999507    63656023@N00    grifan
86999508    63656023@N00    grifan
86999509    63656023@N00    grifan

and I want to read it to a matrix that keeps each column separate.

How could I do it?

Upvotes: 0

Views: 164

Answers (1)

Nick
Nick

Reputation: 3203

Use textscan with a tab (\t) as delimeter:

fid = fopen(fileNm, 'r');
while~feof(fid)
    output = textscan(fid, '%d %s %s', 'Delimiter', '\t')
end

Upvotes: 2

Related Questions