COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

• Follow

```Hello
I have always thought the gradient as the change in values, and thought the Gradient of the below simply was:
gx = 2 -1 -1 0
Matlab produces the result below:
>> [gx gy] = gradient([1 3 2 1;1 3 2 1]);
>> gx

gx =

2.0000    0.5000   -1.0000   -1.0000
2.0000    0.5000   -1.0000   -1.0000

Can someone please tell me how the Gradient is implemented for these real values? Think my problem lies in that Im not quite sure of how to differentiate, when it is not a function.

Kind Regards
```
 0
Reply idiotbarn (2) 12/8/2008 11:21:45 PM

```FatMooseHenry <idiotbarn@hotmail.com> wrote in message <8904924.1228767752759.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hello
> I have always thought the gradient as the change in values, and thought the Gradient of the below simply was:
> gx = 2 -1 -1 0
> Matlab produces the result below:
> >> [gx gy] = gradient([1 3 2 1;1 3 2 1]);
> >> gx
>
> gx =
>
>     2.0000    0.5000   -1.0000   -1.0000
>     2.0000    0.5000   -1.0000   -1.0000
>
> Can someone please tell me how the Gradient is implemented for these real values? Think my problem lies in that Im not quite sure of how to differentiate, when it is not a function.
>
> Kind Regards

Yep. Looks pretty weird to me.

```
 0
Reply mjacobson.removethis (562) 12/8/2008 8:43:03 PM

```FatMooseHenry <idiotbarn@hotmail.com> wrote in message <8904924.1228767752759.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hello
> I have always thought the gradient as the change in values, and thought the Gradient of the below simply was:
> gx = 2 -1 -1 0
> Matlab produces the result below:
> >> [gx gy] = gradient([1 3 2 1;1 3 2 1]);
> >> gx
>
> gx =
>
>     2.0000    0.5000   -1.0000   -1.0000
>     2.0000    0.5000   -1.0000   -1.0000
>
> Can someone please tell me how the Gradient is implemented for these real values? Think my problem lies in that Im not quite sure of how to differentiate, when it is not a function.
>

Since I've never used gradient, I also find it peculiar that gx is supposed to be the horizontal gradient.

When will people finally realize that the x-axis should always be vertical pointing downward and not horizontal pointing left to right?

```
 0
Reply mjacobson.removethis (562) 12/8/2008 8:46:03 PM

```FatMooseHenry <idiotbarn@hotmail.com> wrote in message <8904924.1228767752759.JavaMail.jakarta@nitrogen.mathforum.org>...
> Hello
> I have always thought the gradient as the change in values, and thought the Gradient of the below simply was:
> gx = 2 -1 -1 0
> Matlab produces the result below:
> >> [gx gy] = gradient([1 3 2 1;1 3 2 1]);
> >> gx
>
> gx =
>
>     2.0000    0.5000   -1.0000   -1.0000
>     2.0000    0.5000   -1.0000   -1.0000
>
> Can someone please tell me how the Gradient is implemented for these real values? Think my problem lies in that Im not quite sure of how to differentiate, when it is not a function.
>
> Kind Regards

It's "centered differences"

The first element is the difference of elements one and two, the last is difference between 3 and 4.  The second is the average of 2 and -1, the 3rd is average of -1 and -1.

So the outside's are differences (first derivative), middle elements are (g(idx+1) - g(idx-1))/2, an approx of the 2nd derivative.

```
 0
Reply not.real1 (274) 12/8/2008 8:52:02 PM

3 Replies
74 Views

Similiar Articles:

7/24/2012 11:56:33 AM