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 #45405 is a reply to message #45403] Fri, 09 September 2005 01:40 Go to previous message
Timm Weitkamp is currently offline  Timm Weitkamp
Messages: 66
Registered: August 2002
Member
pravesh.subramanian@gmail.com wrote:

> 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

I assume that by "x = y = 300" you actually mean that x and y are 1D
arrays with approximately 300 elements each, right? The formula then
describes a 2D Gaussian with width "s". Here is a way of doing it:

s = 100.0 ; or whatever other value you want for the width
nx = 300 ; number of elements of x
ny = 300 ; number of elements of y
x = FINDGEN(nx) ; your x values
y = FINDGEN(ny) ; your y values

; Blow x and y up to two dimensions

xx = x # (1.0 + FLTARR(ny))
yy = y ## (1.0 + FLTARR(nx))

; ... and then the calculation of the Gaussian is as easy as this:

matrix = 1.0 / (s^2 * 2 * !PI) * EXP(-(xx^2 + yy^2) / (2.0 * s^2))

Hope this helps,
Timm

Timm Weitkamp
ESRF, Grenoble, France
[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: Fri Oct 10 03:36:50 PDT 2025

Total time taken to generate the page: 0.38806 seconds