From: Stefan v. d. W. <st...@su...> - 2005-01-15 19:53:28
|
On Fri, Dec 03, 2004 at 03:12:40AM -0600, Pascal A. Dupuis wrote: > atstr = sprintf("%f,%f", position(1),position(2)); > > str = sprintf("%f", 1e-9) > results in ... 0! > > The following patch seems to work for me: > > --------------------------------------------------- > --- text.m.orig 2004-12-03 10:08:10.000000000 +0100 > +++ text.m 2004-12-03 10:08:42.000000000 +0100 > @@ -147,9 +147,9 @@ > font = ""; > endif > if position(3)!=0, > - atstr = sprintf("%f,%f,%f", position(1),position(2),position(3)); > + atstr = sprintf("%e,%e,%e", position(1),position(2),position(3)); > else > - atstr = sprintf("%f,%f", position(1),position(2)); > + atstr = sprintf("%e,%e", position(1),position(2)); > endif > command = sprintf('gset label "%s" at %s %s %s %s%s', > str, units, atstr, align, rotate, font); > ---------------------------------------------------------- If you do that, bigger numbers will also be printed in engineering notation. I.e. octave:22> sprintf("%e\n", 1024) ans = 1.024000e+03 What is the most common behaviour required of "text"? Regards Stefan |
From: Laurent M. <lau...@mo...> - 2005-01-17 08:12:30
|
On Wed, 12 Jan 2005 15:28:56 +0200 Stefan van der Walt <st...@su...> wrote: > On Fri, Dec 03, 2004 at 03:12:40AM -0600, Pascal A. Dupuis wrote: > > atstr = sprintf("%f,%f", position(1),position(2)); > > > > str = sprintf("%f", 1e-9) > > results in ... 0! > > > > The following patch seems to work for me: > > > > --------------------------------------------------- > > --- text.m.orig 2004-12-03 10:08:10.000000000 +0100 > > +++ text.m 2004-12-03 10:08:42.000000000 +0100 > > @@ -147,9 +147,9 @@ > > font = ""; > > endif > > if position(3)!=0, > > - atstr = sprintf("%f,%f,%f", position(1),position(2),position(3)); > > + atstr = sprintf("%e,%e,%e", position(1),position(2),position(3)); > > else > > - atstr = sprintf("%f,%f", position(1),position(2)); > > + atstr = sprintf("%e,%e", position(1),position(2)); > > endif > > command = sprintf('gset label "%s" at %s %s %s %s%s', > > str, units, atstr, align, rotate, font); > > ---------------------------------------------------------- > > If you do that, bigger numbers will also be printed in engineering > notation. I.e. > > octave:22> sprintf("%e\n", 1024) > ans = 1.024000e+03 May we use sprintf("%g\n", 1024) ? -- Dr. Laurent Mazet: Research Engineer /V\ Centre de Recherche de MOTOROLA Tel: +33 (0)1 69 35 48 30 =-=-=-=-=-=-=-=-=-=-= Email: ma...@cr... |
From: David B. <Dav...@mo...> - 2005-01-17 08:57:59
|
Stefan van der Walt wrote: >On Fri, Dec 03, 2004 at 03:12:40AM -0600, Pascal A. Dupuis wrote: > > >>atstr = sprintf("%f,%f", position(1),position(2)); >> >>str = sprintf("%f", 1e-9) >>results in ... 0! >> >>The following patch seems to work for me: >> >>--------------------------------------------------- >>--- text.m.orig 2004-12-03 10:08:10.000000000 +0100 >>+++ text.m 2004-12-03 10:08:42.000000000 +0100 >>@@ -147,9 +147,9 @@ >> font = ""; >> endif >> if position(3)!=0, >>- atstr = sprintf("%f,%f,%f", position(1),position(2),position(3)); >>+ atstr = sprintf("%e,%e,%e", position(1),position(2),position(3)); >> else >>- atstr = sprintf("%f,%f", position(1),position(2)); >>+ atstr = sprintf("%e,%e", position(1),position(2)); >> endif >> command = sprintf('gset label "%s" at %s %s %s %s%s', >> str, units, atstr, align, rotate, font); >>---------------------------------------------------------- >> >> > >If you do that, bigger numbers will also be printed in engineering >notation. I.e. > >octave:22> sprintf("%e\n", 1024) >ans = 1.024000e+03 > >What is the most common behaviour required of "text"? > >Regards >Stefan > > Stefan the "%e" was replaced with "%g" in octave-forge and committed when Pascale reported the problem. Using "%g" should give the best of both worlds... Regards David -- David Bateman Dav...@mo... Motorola CRM +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary |