entering tide data
David Bateman
dbateman at dbateman.org
Thu Jan 29 14:22:33 CST 2009
Brado wrote:
> Hello,
>
> I'd really appreciate some help to get me started on octave. Surely the
> first steps are the hardest.
>
> Here is my problem: I'd like to import data from a tide gauge. It's in the
> following format:
>
> date+time 006-pwl
>
> it looks something like this in the file:
>
> 2007022+0000 0.229
>
> the first group of numbers are date+time, the second the actual water level
> measurement. How do I modify the appropriate command (load?) to import and
> make sense of this data??
>
> Thanks
>
> B
>
>
>
A bit of regexp magic will do the trick..
fid = fopen("tide.txt");
s = char(fread(fid)).';
fclose(fid);
t = regexp(s,'^\s*(\d+)\+(\d+)\s+([\.\d]+)','tokens','lineanchors');
dte = cellfun(@(x) x(1), t)
tme = cellfun(@(x) x(2), t)
tide = cellfun(@(x) x(3), t)
D.
--
David Bateman dbateman at dbateman.org
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
More information about the Help-octave
mailing list