www.gusucode.com > pde 案例源码 matlab代码程序 > pde/EvaluateGradientsForScalarEllipticProblemExample.m
%% Evaluate Gradients for Scalar Elliptic Problem % Evaluate gradients of the solution to a scalar elliptic problem along a % line. Plot the results. %% % Create the solution to the problem $- \Delta u = 1$ on the L-shaped % membrane with zero Dirichlet boundary conditions. model = createpde; geometryFromEdges(model,@lshapeg); applyBoundaryCondition(model,'dirichlet','edge',1:model.Geometry.NumEdges,'u',0); specifyCoefficients(model,'m',0,... 'd',0,... 'c',1,... 'a',0,... 'f',1); generateMesh(model,'Hmax',0.05); results = solvepde(model); %% % Evaluate gradients of the solution along the straight line from |(x,y) = % (-1,-1)| to |(1,1)|. Plot the results as a quiver plot by using |quiver|. xq = linspace(-1,1,101); yq = xq; [gradx,grady] = evaluateGradient(results,xq,yq); gradx = reshape(gradx,size(xq)); grady = reshape(grady,size(yq)); quiver(xq,yq,gradx,grady) xlabel('x') ylabel('y')