help-octave
[Top][All Lists]
Advanced

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

Re: *printf Understanding


From: Keith Goodman
Subject: Re: *printf Understanding
Date: Tue, 7 Mar 2006 08:53:45 -0800

On 3/7/06, Bill Denney <address@hidden> wrote:
> I have an application where I want to output a file with indenting (the
> XML I was mentioning earlier).  I thought that I would just use the %*s
> feature to output a string that is the size of my indentation, but I found
> that code like
>
> sprintf('%*s', 0, ' ')
>
> returns a single space instead of an empty string as I expected.
>
> Is that the way it's supposed to work?  If so, is there a better method
> for doing this?

Would this work?

>> N = 0; spacer = repmat(' ', 1, N);
>> printf('%s|\n',spacer)
|
>> N = 10; spacer = repmat(' ', 1, N);
>> printf('%s|\n',spacer)
          |
>>

Or '\t'?



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