When a data file contains some header lines before the actual data matrix, octave's dlmread function can be used to read the matrix of data and ignore the headers.
For example,
$cat input_data.m
col1 col2 col3
1, 2, 3
4, 5, 6
7, 8, 9
10, 11, 12
This file contains one header line and a 4x3 data matrix. To read it into octave, create a script called
$cat read_data.m
1;
A = dlmread("input_data.m", SEP=',', R0=1, C0=0);
A
$octave3.2 -qf
octave3.2:1> read_data
A =
1 2 3
4 5 6
7 8 9
10 11 12
For more information on dlmread function, use 'help dlmread' inside octave.
Tested using octave 3.2.4-3 on Debian stable (Lenny).
Malayamarutham is a mellifluous raaga in carnatic music which will make one soft at heart. In telugu, malaya maarutham is a cool evening breeze which invigorates mind, body & heart.
Feedback, suggestions, criticisms, typos, mistakes, errors etc., (no matter how small you think they are) on the articles of this blog are very welcome. They can be directed to kamaraju at gmail dot com.
Sunday, April 25, 2010
load data file with header lines in octave
Labels:
header line mania,
octave tips,
reading data files
Subscribe to:
Post Comments (Atom)
Blog Archive
-
►
2007
(38)
-
►
April
(8)
- gnuplot with GNU readline and history support
- calculate md5sums in windows
- recipe for building texmacs package with pdebuild
- recipe for building texmacs package with pbuilder
- executing octave scripts
- insert page numbers in a texmacs document
- copy paste code into blogger
- Google groups feature suggestions - 1
-
►
March
(11)
- exiting full screen modes
- search for one word and exclude another word in vi...
- Disable system bell
- inserting a horizontal line in texmacs
- list of all Debian machines
- convert mp3 to wav
- ఎన్ని సార్లు విన్నా ఇంకా ఇంకా వినాలనిపించే ...
- gnuplot realted links
- various ways of reading man pages
- My experience with knujon
-
►
April
(8)
0 comments:
Post a Comment