Easy reading of a data file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Easy reading of a data file

Pettiaux Nicolas
        Hi,

        We are starting to use Octave. Is there an easy way to
read column data files in octave or does it have to be done
with the other C-style input/output functions ?

ie.

AI want to read in a file containing

a aa
b bb
c cc
...

        Thanks,

        Nicolas


==========================================================================
|  Nicolas Pettiaux          Laboratoire de physique biomedicale, CP 613 |
|  ULB, Campus Erasme      Route de Lennik 808, B-1070 Brussels, Belgium |
|  Tel: +32.2.555.61.35, Fax: +32.2.555.61.62, Email: [hidden email] |
==========================================================================

Reply | Threaded
Open this post in threaded view
|

Re: Easy reading of a data file

John Eaton-4
[hidden email] (Pettiaux Nicolas) wrote:

: We are starting to use Octave. Is there an easy way to
: read column data files in octave or does it have to be done
: with the other C-style input/output functions ?
:
: ie.
:
: AI want to read in a file containing
:
: a aa
: b bb
: c cc
: ...

You can do it with C-style I/O functions, but it is probably much
faster to do it with the load command.  To do this, you will need to
add some comments to the beginning of the file that tell Octave how
much data to expect, and the variable name to store it in.  The load
command expects data in the same format as created by the save
command.  You can do something like

  a = [1,2;3,4]
  save - a

to get an example of the format used by the save command.  (Using `-'
as the file name tells save to print to the screen instead of saving
the data in a file.)

jwe