comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: realizing the formula in idl
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: realizing the formula in idl [message #45403 is a reply to message #45400] Fri, 09 September 2005 00:57 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
pravesh.subramanian@gmail.com writes:
> Hello,
> How do I realize this formula in IDL?
>
> matrix(x, y) = 1/(s^2 * 2 * pi) * Exp (-(x^2 + y^2)/2 * s^2)
>
> let's say x = y = 300

Greetings, your question is not quite complete. Are X and Y indices,
or are they the independent variables of the function?

Assuming you have a 2D function, and you have the grid positions that
you want to sample as 1D arrays in X and Y, then first I typically
make a 2D array of grid positions,

XX = X # (Y*0+1)
YY = (X*0+1) # Y

Then it's a simple matter to compute the function almost exactly as
you wrote it,

MATRIX = 1/(s^2 * 2 * !dpi) * Exp (-(xx^2 + yy^2)/2 * s^2)

If you want to avoid underflow errors, then there are two extra steps
to mask them out,

U = -(xx^2 + yy^2)/2 * s^2
MASK = ABS(U) LT 60 ;; May need to tweak this number
MATRIX = MASK/(s^2 * 2 * !dpi) * Exp (-(xx^2 + yy^2)/2 * s^2 * MASK)

Good luck,
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: error bars
Next Topic: How to create an image from the last columns of a stack of images?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 20:36:29 PDT 2025

Total time taken to generate the page: 0.79765 seconds