evaluateGradient missing from pde toolbox

조회 수: 2 (최근 30일)
Heidi
Heidi 2019년 5월 2일
댓글: Heidi 2019년 5월 3일
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
Heidi
Heidi 2019년 5월 2일
The question is, why am I missing these functions and is there any way to access them?

댓글을 달려면 로그인하십시오.

채택된 답변

Ravi Kumar
Ravi Kumar 2019년 5월 3일
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
Heidi
Heidi 2019년 5월 3일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Geometry and Mesh에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by