help-octave
[Top][All Lists]
Advanced

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

Re: printf() and matrices bug?


From: Miquel Cabanas
Subject: Re: printf() and matrices bug?
Date: Mon, 20 Feb 2006 10:42:00 +0100

hi,

this is an excerpt from the Matlab documentation for fprintf, the
equivalent of Octave's printf,

The fprintf function is vectorized for nonscalar arguments. The function
recycles the format string through the elements of A (columnwise) until
all the elements are used up. The function then continues in a similar
manner through any additional matrix arguments.

as you can read, the matrix is vectorized columnwise (see the output of
a(:)), hence, if you want printf/fprintf to print your matrix as is, you
will have to transpose it first, e.g.

a = rand(3)
printf("%f %f %f\n", a')

Miquel

On Mon, 2006-02-20 at 09:16 +0100, Maarten D. de Jong wrote:
> It seems that there is a bug (or rather, unexpected feature) when using
> printf() in conjunction with matrices in Octave 2.1.71. If I enter
> 
> a = rand(3)
> printf("%f %f %f\n", a)
> 
> then what is printed is a.', not a. I haven't been able to find anything
> relating to this issue in the mailing list archives (neither bug nor
> help), hence my question: is this as intended (for example, to be
> compatible with Matlab) or a bug?





-------------------------------------------------------------
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
-------------------------------------------------------------



reply via email to

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