From help-request at octave dot org Tue Dec 6 08:51:30 2005 Subject: Re: How to suppress unneeded output while using "save" From: "John W. Eaton" To: Bill Denney Cc: "Steve C. Thompson" , paladini@rz.uni-potsdam.de, help@octave.org Date: Tue, 6 Dec 2005 09:51:16 -0500 On 6-Dec-2005, 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.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------