Hi guys

I am sure I am being stupid with this question. My apologies in advance.

I have an unequal spacing grid of points, say, size(grid) = [100 200].

I want to evaluate the gradient of a function f(grid) along both dimensions of the grid.

How can I do this?

Just to play around with function gradientFD, I coded :

x = 0:0.01:10;

y = 0:0.01:5;

[X,Y] = meshgrid(x,y);

f = cos(2*pi*X).*Y;

dfx = gradientFD(f,x,2);

dfy = gradientFD(f,y,1);

dfx is evaluated correctly, whereas dfy is not.

What is wrong with my understanding of gradientFD function ?

Thanks much