Re: how to create a LOG array from A to B [message #78988] |
Fri, 13 January 2012 13:32 |
Mark Piper
Messages: 198 Registered: December 2009
|
Senior Member |
|
|
On 1/12/2012 2:43 PM, nata wrote:
> I got it !
>
> a=1.5
> b=5.45
> N=20
>
> elev=FINDGEN(N)*(ALOG10(b)-ALOG10(a))/(N-1)+ALOG10(a)
> elev=10.^elev
>
> PLOT, elev, REPLICATE(1,N), YR=[0,2], XR=[a,b], /XLOG, /XS, /YS,
> PSYM=7
>
> nata
I know I'm late with this, but several years ago I wrote a routine for
just this purpose. Get it here:
http://www.exelisvis.com/Default.aspx?tabid=1540&id=1231
Example:
IDL> a = findgen_alog10(5.4, 56.8, 10)
IDL> print, a
5.40000 7.01365 9.10950 11.8316 15.3672
19.9593 25.9237 33.6703
43.7318 56.8000
IDL> plot, a, a, /xlog, /ylog, psym=5
mp
|
|
|
Re: how to create a LOG array from A to B [message #78994 is a reply to message #78988] |
Thu, 12 January 2012 13:43  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
I got it !
a=1.5
b=5.45
N=20
elev=FINDGEN(N)*(ALOG10(b)-ALOG10(a))/(N-1)+ALOG10(a)
elev=10.^elev
PLOT, elev, REPLICATE(1,N), YR=[0,2], XR=[a,b], /XLOG, /XS, /YS,
PSYM=7
nata
|
|
|
Re: how to create a LOG array from A to B [message #78995 is a reply to message #78994] |
Thu, 12 January 2012 13:50  |
manodeep@gmail.com
Messages: 33 Registered: June 2006
|
Member |
|
|
On Jan 12, 3:41 pm, nata <bernat.puigdomen...@gmail.com> wrote:
> Michael,
>
> Your code works but this is not exactly what I need.
> Using your method I get something like this :
>
> a=1.5
> b=5.45
> N=20
> elev=ALOG10(FINDGEN(N) * (10.^b - 10.^a) / (N - 1.) + 10.^a)
> PLOT, elev, REPLICATE(1,N), YR=[0,2], XR=[a,b], /XLOG, /XS, /YS,
> PSYM=7
>
> And I would like to have all the points equal-spaced on the plot. Do
> you think this is possible ?
> Thank you for your help,
>
> nata
Hi Nata,
As long as A and B are > 0, you can use this:
log_limits = alog10([A,B])
log_binsize = (log_limits[1]-log_limits[0])/(N-1.0)
log_values = findgen(N)*log_binsize + log_limits[0]
values = 10.0d^log_values
HTH,
Manodeep
|
|
|
Re: how to create a LOG array from A to B [message #78996 is a reply to message #78994] |
Thu, 12 January 2012 13:41  |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Michael,
Your code works but this is not exactly what I need.
Using your method I get something like this :
a=1.5
b=5.45
N=20
elev=ALOG10(FINDGEN(N) * (10.^b - 10.^a) / (N - 1.) + 10.^a)
PLOT, elev, REPLICATE(1,N), YR=[0,2], XR=[a,b], /XLOG, /XS, /YS,
PSYM=7
And I would like to have all the points equal-spaced on the plot. Do
you think this is possible ?
Thank you for your help,
nata
|
|
|
|
Re: how to create a LOG array from A to B [message #79001 is a reply to message #78999] |
Thu, 12 January 2012 11:52  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On 1/12/12 12:27 PM, nata wrote:
> Hello guys,
>
> If I want to create an array of N positions from A to B I can do it
> like this :
> result=FINDGEN(N)*(B-A)/(N-1)+A
>
> Right now I would like to create the same array but with a logaritmic
> "distribution" and for any positive A and B.
> For example, for A = 0, B = 1 and N=10 the result should be
> ALOG10(1+FINDGEN(10))
>
> This is easy if A and B are powers of 10 but I don't know how to solve
> this problem with any other numbers.
> Thnak you in advance for your help,
>
> nata
Just use your result at the top, but use 10.^a and 10.^b instead of a and b:
IDL> plot, alog10(findgen(n) * (10.^b - 10.^a) / (n - 1.) + 10.^a)
Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
|
|
|