Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: extract dynamically the headerlines row numvber by string/number
Date: Tue, 1 Jul 2008 15:20:19 +0000 (UTC)
Organization: Pierburg GmbH
Lines: 58
Message-ID: <g4dhvj$8id$1@fred.mathworks.com>
References: <2924bec5-2274-4b3b-8354-20b34f59add2@m3g2000hsc.googlegroups.com>  <155421db-2dae-4c05-a69a-7bd91a8f6793@r66g2000hsg.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1214925619 8781 172.30.248.35 (1 Jul 2008 15:20:19 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 1 Jul 2008 15:20:19 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 872224
Xref: news.mathworks.com comp.soft-sys.matlab:476901



Engeltje <Engeltje81@gmail.com> wrote in message <155421db-
2dae-4c05-a69a-7bd91a8f6793@r66g2000hsg.googlegroups.com>...
[..]
> The problem I had I found a solution using the function
> txt2mat(filename,0,1) I take the first colomn and then I 
made a
> function that check if the result vector isnan (in this 
case increase
> first index) else increase second index.
> so thx to be interested!
> Now I actually have a new problem!
> I have some data in which part of the colomn is emtpy.
> Example:
> 
> timestamp X Y value
> 10
> 20 3.2 3.4 4
> 30
> 40 1.2 2.7 10
> 
> I use:
> values=textscan(filename,'%d %f %f %d', 
4,'headerlines',1);
> 
> [TS,GazePointX,GazePointY,val]=values{:}
> 
> the problem is that it stops at TS=10, and the others are 
empty
> Can u help me?
> angelo


Hi Angelo,

did you try to use txt2mat with the filename as the only 
argument, i.e.

A = txt2mat(filename)

that would give 

A =
   10.0000       NaN       NaN       NaN
   20.0000    3.2000    3.4000    4.0000
   30.0000       NaN       NaN       NaN
   40.0000    1.2000    2.7000   10.0000

for your example ? txt2mat has built in an automatic header 
line and column number detection. If you know the number of 
header lines in advance, you can also write

A = txt2mat(filename,1)  % or
A = txt2mat(filename,'NumHeaderLines',1)

for a single header line, to be sure.

Hth, regards
Andres