

Dear ladies and gentlemen!
I use the command "save" to save a matrix in a datafile. That works pretty
well.
But octave also writes the following information in this datafile:
# Created by Octave 2.1.57, Sun Dec 04 12:37:37 2005
# name: speedsc1
# type: matrix
# rows: 30
# columns: 337
How can I suppress this additional output?
Thank you very much!
Claudia Paladini

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Tue, Dec 06, 2005 at 12:11:18PM +0100, [hidden email] wrote:
> Dear ladies and gentlemen!
> I use the command "save" to save a matrix in a datafile. That works pretty
> well.
> But octave also writes the following information in this datafile:
>
> # Created by Octave 2.1.57, Sun Dec 04 12:37:37 2005
> # name: speedsc1
> # type: matrix
> # rows: 30
> # columns: 337
>
> How can I suppress this additional output?
If you remove those lines, you will not be able to load the file
again. If you still wish to do so, simply pipe the file through `grep':
$ cat data.txt  grep v "#" > newdata.txt
St?fan

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Dec 6, 2005, at 6:47 AM, Stefan van der Walt wrote:
> On Tue, Dec 06, 2005 at 12:11:18PM +0100, [hidden email]
> wrote:
>> Dear ladies and gentlemen!
>> I use the command "save" to save a matrix in a datafile. That works
>> pretty
>> well.
>> But octave also writes the following information in this datafile:
>>
>> # Created by Octave 2.1.57, Sun Dec 04 12:37:37 2005
>> # name: speedsc1
>> # type: matrix
>> # rows: 30
>> # columns: 337
>>
>> How can I suppress this additional output?
>
> If you remove those lines, you will not be able to load the file
> again. If you still wish to do so, simply pipe the file through
> `grep':
>
> $ cat data.txt  grep v "#" > newdata.txt
Or you can use dlmwrite
dlmwrite('outfile',A,' ')
 Paul

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Tue, 6 Dec 2005 [hidden email] wrote:
> Dear ladies and gentlemen!
> I use the command "save" to save a matrix in a datafile. That works pretty
> well.
> But octave also writes the following information in this datafile:
>
> # Created by Octave 2.1.57, Sun Dec 04 12:37:37 2005
> # name: speedsc1
> # type: matrix
> # rows: 30
> # columns: 337
>
> How can I suppress this additional output?
Here's a perl script I wrote for removing header lines. This overwrites
files and can be used on collections of files using wildcard characters.
Suppose you name this script "no_headers" then you could do things like
this:
no_headers *.out outfiles/*
begin script on next line
#!/usr/bin/perl i p
# This removes the initial header lines of an octave ascii data file
BEGIN{undef $/} s/(# [^\n]*\n)+ / /
end script on previous line
Someone claimed that if you remove the header information, you cannot
reload the matrix in Octave. That depends. If the file holds a single
matrix, you can still use "load" to bring that matrix into Octave, but you
will have to give it an appropriate name.
I assume that you want remove the header info because you want to import
the data into a different program.
Mike

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On 06 Dec 05 08:12AM, Paul Kienzle wrote:
>>On Tue, Dec 06, 2005 at 12:11:18PM +0100, [hidden email] wrote:
>>> How can I suppress this additional output?
>>
>> $ cat data.txt  grep v "#" > newdata.txt
>
> Or you can use dlmwrite
Or `fprintf':
fid = fopen (filename, 'w');
for i = 1 : n
fprintf (fid, '%f %f %f \n', a(1), a(2), a(3));
end
fclose (fid);
Or there abouts.
Steve

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Tue, 6 Dec 2005, Steve C. Thompson wrote:
> Or `fprintf':
>
> fid = fopen (filename, 'w');
> for i = 1 : n
> fprintf (fid, '%f %f %f \n', a(1), a(2), a(3));
> end
> fclose (fid);
>
> Or there abouts.
I think that fprintf is more vectorized, so a more general version (not
requiring only 3 data points per row in a) would be
fid = fopen (filename, 'w');
for i = 1:size(a,1)
fprintf(fid, "%d ", a(i,:));
fprintf(fid, "\n");
endfor
fclose(fid);
Test that out, but it should be close.
Bill

"SF author Larry Niven proposed a beer mug that [...] automatically,
silently refilled itself from the keg."
"Hmm, in that case, the obvious course of action is to eat the mug."
 DeadVulcan on slashdot

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On 6Dec2005, Bill Denney wrote:
 On Tue, 6 Dec 2005, Steve C. Thompson wrote:
 > Or `fprintf':
 >
 > fid = fopen (filename, 'w');
 > for i = 1 : n
 > fprintf (fid, '%f %f %f \n', a(1), a(2), a(3));
 > end
 > fclose (fid);
 >
 > Or there abouts.

 I think that fprintf is more vectorized, so a more general version (not
 requiring only 3 data points per row in a) would be

 fid = fopen (filename, 'w');
 for i = 1:size(a,1)
 fprintf(fid, "%d ", a(i,:));
 fprintf(fid, "\n");
 endfor
 fclose(fid);

 Test that out, but it should be close.
Or even
fprintf (fid, strcat (repmat (" %f", 1, columns (a)), "\n"), a');
though you may want to get a little fancier with the format string so
that there is not a space at the beginning or end of each line.
jwe

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


Assuming you saved the variable like this...
>> save ascii "variable.txt" variable;
I then use notepad, open the file, block the header, and
delete it. Then save, and done.
...youse guys can stop laughing now.
 Robert 
On Tue, 6 Dec 2005 12:11:18 +0100
[hidden email] wrote:
> Dear ladies and gentlemen!
> I use the command "save" to save a matrix in a
> datafile. That works pretty
> well.
> But octave also writes the following information in this
> datafile:
>
> # Created by Octave 2.1.57, Sun Dec 04 12:37:37 2005
> # name: speedsc1
> # type: matrix
> # rows: 30
> # columns: 337
>
> How can I suppress this additional output?
>
>
> Thank you very much!
>
> Claudia Paladini
>

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Tue, 6 Dec 2005, Robert A. Macy wrote:
> Assuming you saved the variable like this...
>
>>> save ascii "variable.txt" variable;
>
> I then use notepad, open the file, block the header, and delete it.
> Then save, and done.
>
> ...youse guys can stop laughing now.
I am glad you were joking! Try doing that with 10,000 output files.
After the first 1,243 you probably get pretty good at it.
More seriously, about 12 years ago I used to do that kind of thing on a
pentium PC using macros in WordPerfect 5.1. It really was kinda neat.
It could open a directory, take one file at a time, edit it (sometimes in
very sophisticated ways), save it elsewhere, delete the original, go to
the next file in the directory and repeat until done.
Now I use perl and I'm much, much happier.
Mike

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html


On Dec 6, 2005, at 9:51 AM, John W. Eaton wrote:
> Or even
>
> fprintf (fid, strcat (repmat (" %f", 1, columns (a)), "\n"), a');
>
> though you may want to get a little fancier with the format string so
> that there is not a space at the beginning or end of each line.
See for example the following two lines from dlmwrite:
template = [ precision, repmat([delim,precision],1,columns(A)1),
newline ];
fprintf(fid,template,A.');
 Paul

Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.orgHow to fund new projects: http://www.octave.org/funding.htmlSubscription information: http://www.octave.org/archive.html

