Taking gradient of solution and plotting results in very weird and unsmooth graphs?

8 ビュー (過去 30 日間)
Mark Lepage
Mark Lepage 2018 年 3 月 8 日
回答済み: Ravi Kumar 2018 年 3 月 8 日
Hello,
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:
%interpolate PDE result
[X,Y,Z] = meshgrid(-(diam-1):diam,-(diam-1):diam,-(height-1):height);
V = interpolateSolution(result,X,Y,Z);
V = reshape(V,size(X));
%Calculate gradient
[Ex,Ey,Ez] = gradient(V);
Ex = -Ex;
Ey = -Ey;
Ez = -Ez;
%Slice and plot z slice vectors
sliceEx = Ex(xslice,:,:);
figure, contourf(sliceEx,50)

回答 (1 件)

Ravi Kumar
Ravi Kumar 2018 年 3 月 8 日
I would suggest you use the evaluateGradient function directly instead of interpolating the solution and then finding its gradients.

カテゴリ

Help Center および File ExchangeGeometry and Mesh についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by