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.
Search This Blog
Sunday, April 25, 2010
Subscribe to:
Posts (Atom)