Matthias Brennwald wrote:
On Aug 10, 2009, at 5:03 PM, Christoph Ellenberger wrote:
I usually use sed to straighten the data and then do the load
thing....
something like:
cmd=['sed -n -e "/^ *[0-9]/p" ' fname ">" Tfname];
if (system(cmd,1))
error("Fehler 1");
end
xx=load(Tfname);
where fname is the filename and tfname is some temporary filename
which I remove afterword with....
cmd=["rm " Tfname];
if (system(cmd,1))
error("Fehler 4");
end
but this depends on what structure do you want afterward. I
sometimes have the coulumnames in the file as well and create a
cellarray with the datapoints called Data.X, Data.Y etc. as well.
Hope this helps
Christoph
Ok, but this requires sed to be available. My code needs to work
with non-unixy machines, too.
Try reading the header lines using fgetl and the rest of the data
with fscanf.
Not tested:
function tdm = tdmread(path2tdmfile)
[fid, msg] = fopen(path2tdmfile, 'r');
if fid < 3, error(msg), endif
first = fgetl(fid);
second = fgetl(fid);
data = fscanf(fid, '%f%f', Inf)
tdm = struct('header', {first; second}, 'data', data);
fclose(fid);
HTH, Michael