MathGroup Archive 2010

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

Search the Archive

Re: discrete numerical 2D gradient

On Tue, Oct 12, 2010 at 1:49 PM, Sebastian Schmitt
<sschmitt at> wrote:

> I have 2D data represented as a matrix. I would like to obtain the
> gradient.
> ...
> Is there a better (both mathematical and Mathematical) to construct the
> y-derivatives (dyMatrix)?

I would use ListInterpolation on your dataMatrix.  The result is an
InterpolatingFunction that you can manipulate in all sorts of ways.

dataMatrix = Table[i*j, {i, 10}, {j, 10}];
f = ListInterpolation[dataMatrix, {{0, 1}, {0, 1}}];
grad[x_, y_] = {Derivative[1, 0][f][x, y],
   Derivative[0, 1][f][x, y]};
VectorPlot[grad[x, y], {x, 0, 1}, {y, 0, 1}]

Mark McClure

  • Prev by Date: Re: How to concatenate matrices?
  • Next by Date: Re: something nice I found today, return multiple values from a function
  • Previous by thread: discrete numerical 2D gradient
  • Next by thread: Re: Limitations of Minimize? Time to buy a new PC for Mathematica?