Discussion:
Header created in saving variables
(too old to reply)
Uri Barkan
2007-07-19 16:17:40 UTC
Permalink
Hi everyone,

I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
used:

save("-text", "var.txt", "var");

I got the following header in var.txt:

# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
<***@localhost>
# name: var
# type: matrix
# rows: 1
# columns: 40

Of course I can't use the file this way. How can I save the variable
to a text file without the header?

Thanks!
highegg
2007-07-20 04:59:39 UTC
Permalink
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
I can think of two possibilities:
1. use fprintf instead
2. strip off the comments after save:
system('sed -i -e"/^#/d" var.txt') (if you have sed)
Uri Barkan
2007-07-20 05:49:42 UTC
Permalink
Thanks. I was sure there as an option I wasn't aware of to cancel the
header printing. It looks a bit odd to me, to force the user to add
those few lines. Also not so Matlab-compatible. I don't have sed, so I
guess I need to print number by number in fprintf.

Thanks for your help.
david bateman
2007-07-20 09:11:27 UTC
Permalink
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable

save('-ascii','var.txt','var')

instead..

D.
highegg
2007-07-20 09:41:21 UTC
Permalink
Post by david bateman
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable
save('-ascii','var.txt','var')
instead..
D.
Interesting - I think this didn't work in Octave 2.1.x.
david bateman
2007-07-23 13:05:57 UTC
Permalink
Post by highegg
Post by david bateman
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable
save('-ascii','var.txt','var')
instead..
D.
Interesting - I think this didn't work in Octave 2.1.x.
Yes this changed in the 2.9 as matlab had the "-ascii" flag for this
single variable text file format. In 2.1.73 you'll find both "-text"
and "-ascii" save with the header, but the "-ascii" flag gives a
warning message to use the "-text" flag instead as the behavior of "-
ascii" will be changed... It was in 2.9.3 I believe..

D.

Uri Barkan
2007-07-20 11:05:29 UTC
Permalink
Post by david bateman
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable
save('-ascii','var.txt','var')
instead..
D.
I tried the second command format of David, I still get the header in
the text file. Was it supposed to do something else?
highegg
2007-07-20 11:20:54 UTC
Permalink
Post by Uri Barkan
Post by david bateman
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable
save('-ascii','var.txt','var')
instead..
D.
I tried the second command format of David, I still get the header in
the text file. Was it supposed to do something else?
Yes, in version 2.9.x, it writes a file without the header.
Uri Barkan
2007-07-20 11:51:35 UTC
Permalink
Post by highegg
Post by Uri Barkan
Post by david bateman
Post by Uri Barkan
Hi everyone,
I'm a newbie to Octave. I've tried to save a variable as a text file,
because I use the file as an input to a program written in C. When I
save("-text", "var.txt", "var");
# Created by Octave 2.1.73, Thu Jul 19 18:40:02 2007 IDT
# name: var
# type: matrix
# rows: 1
# columns: 40
Of course I can't use the file this way. How can I save the variable
to a text file without the header?
Thanks!
Try the matlab compatiable
save('-ascii','var.txt','var')
instead..
D.
I tried the second command format of David, I still get the header in
the text file. Was it supposed to do something else?
Yes, in version 2.9.x, it writes a file without the header.
Hmmm, so I need to update my version. OK, thanks.
Continue reading on narkive:
Loading...