help-octave
[Top][All Lists]
Advanced

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

Re: Passing values


From: Paul Kienzle
Subject: Re: Passing values
Date: Mon, 13 May 2002 05:18:33 -0400

On Sun, May 12, 2002 at 04:22:56PM -0500, Mike Miller wrote:
> On Sun, 12 May 2002, Mike Miller wrote:
> 

<snip>

> The first argument tells octave which output format to use.  The problem
> > is that this works only if the second argument is not longer (in number
> > of characters) than the first argument!  If the second argument is
> > longer, the first argument will have appended spaces, and octave doesn't
> > know what to do with things like format('long  ').  So what I need is a
> > command called 'despace' (or whatever) that will fix things:
> >
> > format(despace('long  '))   or   format(despace(argv(1,:)))
> >
> > despace would take a string as input and it would return the same string
> > as output, but with any spaces from the end of the string removed.

It's called 'deblank'

> I figured it out.  I think this will always work, and it is fairly
> efficient.  I welcome any better methods...

You've rediscovered deblank's algorthm, though deblank trims an array to
the length of the longest string, and trims \0 as well as blank.

Paul Kienzle
address@hidden



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