MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to calculate gradient and laplace of a list


Hi,
you can do this using ListCorrelate or ListConvolve. For ListCorelate 
the Kernel would be:
x component of Gradient: ker={{0,0,0},{-1,0,1},{0,0,0}}/2
y component of Gradient: ker={{0,1,0},{0,0,0},{0,-1,0}}/2
Laplacian: ker={{0,1,0},{1,-4,1},{0,1,0}}/4
you would then write:
ListCorrelate[ker,matrix]
To plot you can use: ListPlotVectorField from: Graphics`PlotField`. But 
you first have to prepare the data. Assume that gradx and grady are 
matrixes with the corresponding components, then the gradient matrix is:
grad=Transpose[{gradx, grady}, {3, 1, 2}]
and we get a Plot by:
<<Graphics`PlotField`
ListPlotVectorField[grad]
Daniel


leoshen wrote:
> Hi, guys
> I have a matrix of n*m read from a file. mathematica has built in function 
> to do discrete fourier transform of the list.
> Can I calculate the gradient and the laplace of the matrix?
> I can use the listcontourplot to plot the matrix, Is there any way to plot 
> the gradient plot of it?
> 
> 
> 
> 


  • Prev by Date: Re: FourierTransform help
  • Next by Date: 2D interpolation
  • Previous by thread: Re: How to calculate gradient and laplace of a list
  • Next by thread: Re: Running Galois.m on Version 2.2.2