help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scientific data - Reading files


From: Paul Kienzle
Subject: Re: Scientific data - Reading files
Date: Mon, 12 Aug 2002 14:04:19 -0400

You could use the "paste" command in unix to build the file:

        address@hidden prog]$ cat >f1.dat <<EOF
        > 1 
        > 2
        > 3
        > EOF
        address@hidden prog]$ cat >f2.dat <<EOF
        > 4
        > 5
        > 6
        > EOF
        address@hidden prog]$ paste f1.dat f2.dat > tmp.dat
        address@hidden prog]$ octave -q
        octave:1> f = load('tmp.dat')
        f =

          1  4
          2  5
          3  6


You can execute the paste command from within octave, but you have to
build it up first.   The following function should do this.

WARNING! Untested code ahead!
function dat = loadpaste(prefix)
        # get the file list
        files = glob([prefix, "*.DAT"]);

Is this list sorted?  I believe it will be sorted alphabetically,
which means that E1431A11.DAT will come before E1431A2.DAT.  You
can avoid this by naming your files E1431A011.DAT and E1431A002.DAT.

        # add a blank to the end of each line
        files = [ files, setstr(toascii(" ")*ones(rows(files),1)) ];

        # build and run the paste command
        tmpdat = tmpnam;
        system(sprintf("paste %s > %s", files', tmpdat));

        # load the matrix
        dat = load(tmpdat);

        # remove the temporary file
        unlink(tmpdat);
endfunction

Paul Kienzle
address@hidden

On Mon, Aug 12, 2002 at 03:02:15AM -0500, Nils Wagner wrote:
> Hi,
> 
> I have collected acceleration data by a multi-channel data acquisition
> system. Each file  (E1431A*.DAT) contains
> one column with real numbers. The contents of the i-th file should be
> stored in the i-th row of a data matrix A.
> How can I manage this task efficiently ? Are there suitable modules for
> this purpose ? 
> A small example would be appreciated.
> 
> Nils
> 
> 
> 
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.octave.org
> How to fund new projects:  http://www.octave.org/funding.html
> Subscription information:  http://www.octave.org/archive.html
> -------------------------------------------------------------
> 



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]