Re: discrete numerical 2D gradient
- To: mathgroup at smc.vnet.net
- Subject: [mg113121] Re: discrete numerical 2D gradient
- From: Mark McClure <mcmcclur at unca.edu>
- Date: Wed, 13 Oct 2010 23:26:54 -0400 (EDT)
- References: <201010121749.NAA03478@smc.vnet.net>
On Tue, Oct 12, 2010 at 1:49 PM, Sebastian Schmitt
<sschmitt at physi.uni-heidelberg.de> 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
- References:
- discrete numerical 2D gradient
- From: Sebastian Schmitt <sschmitt@physi.uni-heidelberg.de>
- discrete numerical 2D gradient