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

Home » Public Forums » archive » Gradient of two dimensional field
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: Gradient of two dimensional field [message #8291 is a reply to message #8200] Wed, 19 February 1997 00:00 Go to previous messageGo to previous message
stockwell is currently offline  stockwell
Messages: 1
Registered: February 1997
Junior Member
In article <yckohdg23jj.fsf@hmi.de> Wilpert_Martin <wilpert-m@hmi.de> writes:
> From: Wilpert_Martin <wilpert-m@hmi.de>
> Subject: Gradient of two dimensional field
> Date: 19 Feb 1997 16:56:00 +0100

> Hi everybody,
> we want to determine the electrical field from a given potential,
> i.e. we have to calculate the gradient of a two dimensional array.
> Has anybody a idl-pvwave procedure to do this task?
> Thank you in advance
> Martin Wilpert


The gradient is just (d/dx , d/dy)f(x,y)
so you can take the deriv() function on the rows and then the columns
"The DERIV function performs numerical differentiation using 3-point,
Lagrangian interpolation and returns the derivative."

so do this:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;
;; array holds your potential function of size (len,len)
dx = fltarr(len,len)
dy = fltarr(len,len)
; my apologies for the for loop
for i = 0,len-1 do dx(*,i) = deriv(array(0:len-1,i))
for i = 0,len-1 do dy(i,*) = deriv(phase(i,0:len-1))
endfor
vel,dx,dy
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;

dx holds the x component of the gradient
dy holds the y component of the gradient



cheers,
bob

============================================================ =========
R. G. Stockwell | Space and Atmospheric Research Group
Phone: 519-679-2111 X6411 | University of Western Ontario
Fax: 519-661-3129 | London, Ontario, Canada
............................................................ ............................................................ .................
email: stockwell@uwo.ca
WWW: http://www.sar.physics.uwo.ca/~stockwell/time_series.html
" If I have not seen as far as other men, it's
because giants were standing on my shoulders"
============================================================ =========
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Printing array on one line
Next Topic: using GET_KBRD

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

Current Time: Wed Dec 03 21:00:10 PST 2025

Total time taken to generate the page: 1.68014 seconds