evaluateGradient missing from pde toolbox

5 views (last 30 days)
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.
  1 Comment
Heidi
Heidi on 2 May 2019
The question is, why am I missing these functions and is there any way to access them?

Sign in to comment.

Accepted Answer

Ravi Kumar
Ravi Kumar on 3 May 2019
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
  1 Comment
Heidi
Heidi on 3 May 2019
Hi Ravi,
I was hoping to use evaluateGradient on variables that were not from PDEModel, and apparently it still will not work for that. But your code worked fine, and your answer explains how to access those functions in the PDE toolbox.
Thanks!
Heidi

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!