Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: read multi-line data with multiple delimiters
Date: Fri, 24 Oct 2008 19:48:02 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 48
Message-ID: <gdt8pi$f17$1@fred.mathworks.com>
References: <70d4e42d-48e0-4f97-a9d2-83aa4eeed8c2@l76g2000hse.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1224877682 15399 172.30.248.37 (24 Oct 2008 19:48:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 24 Oct 2008 19:48:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:497158


boivie@gmail.com wrote in message <70d4e42d-48e0-4f97-a9d2-83aa4eeed8c2@l76g2000hse.googlegroups.com>...
[..]
> This is what the file looks like:
> 
> /Data
> /X,Y,Longitude,Latitude
> //Flight 0
> //Date 2008/09/27
> Line  0
> -450.0,50.0,147.5445363050,-76.4478227596
> 450.0,50.0,182.4554636951,-76.4478227596
> Line  10
> -450.0,-50.0,146.3500677843,-77.3018107353
> 450.0,-50.0,183.6499322158,-77.3018107353
> Tie  -10
> -360.0,-100.0,149.3523576944,-77.9633702276
> -360.0,100.0,151.3351657935,-76.2267188392
> Tie  0
> -160.0,-100.0,157.9105218900,-78.3092770253
> -160.0,100.0,158.8372826671,-76.5286269834

Hi Ethan,
if it is ok that your 'Line' or 'Tie' flags are represented as 0 or 1 in a double array, there is also a (more convenient?) single command option with txt2mat from the file exchange:

A = txt2mat('c:file.txt','ReplaceExpr',{{'Line','0'},{'Tie','1'}});

The header lines and delimiters are detected automatically (see the doc), and the matrix is padded with NaNs to fill up the rows.

With your example, A would be

0	0	NaN	NaN
-450	50	147.5445	-76.4478
450	50	182.4555	-76.4478
0	10	NaN	NaN
-450	-50	146.3501	-77.3018
450	-50	183.6499	-77.3018
1	-10	NaN	NaN
-360	-100	149.3524	-77.9634
-360	100	151.3352	-76.2267
1	0	NaN	NaN
-160	-100	157.9105	-78.3093
-160	100	158.8373	-76.5286

(short notation just for the ng)

Hth,
regards,
Andres