MATLAB: EvaluateGradient missing from pde toolbox

missing functiontoolbox incomplete

I have an institutional license for Matlab and just downloaded version 2019a along with the PDE toolbox version 3.2 in order to access evaluateGradient.m. Although evaluateGradient is listed in the help page for this toolbox, the function apparently is missing from my download. I get this error:
'Undefined function 'evaluateGradient' for input arguments of type 'double'
And when I navigate to the PDE toolbox folder, the directory appears to exclude most of the functions listed in the documentation.

Best Answer

Hi Heidi,
You need to have a results object in the workspace to access evaliuateGradient on the MATLAB path. Run any PDEModel based example and then you will be able to access it.
evaliuateGradient is a method so you won't be able access it without a resutls object. Copy and paste the following code.
%Create a PDEModel, import geometry, and specify coefficients.
N = 1; % single PDE
pdem = createpde(N);
g = importGeometry(pdem,'Block.stl');
c = 1;
a = 0;
f = 0.1;
specifyCoefficients(pdem,'m',0,'d',0,'c',c,'a',a,'f',f);
%Apply boundary conditions and generate the mesh.
applyBoundaryCondition(pdem,'dirichlet','Face',1:4,'u',0);
applyBoundaryCondition(pdem,'neumann','Face',6,'g',-1);
applyBoundaryCondition(pdem,'neumann','Face',5,'g',1);
generateMesh(pdem);
%Solve the PDE.
R = solvepde(pdem);
%Define a grid of points representing the mid-plane of the plate.
xp = 0:2:100; yp = 0:2:50;
[XX, ZZ] = meshgrid(xp,yp);
YY = 2*ones(size(XX));
%Evaluate gradients of the solution on the mid-plane grid.
[dudx, dudy, dudz] = evaluateGradient(R,XX,YY,ZZ);
%Reshape the gradients to visualize using the MATLAB surf function.
dudxres = reshape(dudx,size(XX));
dudyres = reshape(dudy,size(XX));
dudzres = reshape(dudz,size(XX));
%Visualize the gradients of solution on the mid-plane.
figure
subplot(1,3,1)
surf(XX,ZZ,dudxres)
xlabel('x'); ylabel('y'); zlabel('du/dx');
subplot(1,3,2)
surf(XX,ZZ,dudyres)
xlabel('x'); ylabel('y'); zlabel('du/dy');
subplot(1,3,3)
surf(XX,ZZ,dudzres)
xlabel('x'); ylabel('y'); zlabel('du/dz');
Regards,
Ravi
Related Question