So I am interpolating a PDE solution to a meshgrid, and then taking the gradient of this.
When I plot the resulting gradient as a contour plot, I am getting extremely weird graphs in attachment (attached).
The gradient should be smooth (it is a gradient of a conservative potential field).
Any ideas what I am doing wrong?? Here is my pseudo code:
[X,Y,Z] = meshgrid(-(diam-1):diam,-(diam-1):diam,-(height-1):height);
V = interpolateSolution(result,X,Y,Z);
V = reshape(V,size(X));
[Ex,Ey,Ez] = gradient(V);
Ex = -Ex;
Ey = -Ey;
Ez = -Ez;
sliceEx = Ex(xslice,:,:);