help-octave
[Top][All Lists]
Advanced

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

Writing a commented output to file


From: AlexG1
Subject: Writing a commented output to file
Date: Tue, 5 May 2009 04:55:53 -0700 (PDT)

Hi,

I'm writing a script which eventually needs to write a matrix to a text
file, and prepend some comments to it (e.g. title line and the starting
conditions that led to the output).

For example, if the matrix is

a = 
1 2 3
4 5 6
7 8 9

I want the output file to look like that:

% Some comment 1
% Some comment 2
1 2 3
4 5 6
7 8 9

Now, since the matrices can get quite big I don't want to use printf() for
every line since it may take a lot of time. Ideally I'd like to use save
-ascii to save the matrix and printf() for the comments.

The problem is this - if I'm using save to write the matrix first I can't
prepend the comments since there is no way to open a file for prepending but
only for appending.
If I write the comments first and then call save -ascii it just overwrites
the contents of the output file and the file will only contain the matrix
without the comments.

Any ideas on how I can get both without just using printf() for everything?

Thanks,

Alex 


-- 
View this message in context: 
http://www.nabble.com/Writing-a-commented-output-to-file-tp23385991p23385991.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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