www.gusucode.com > pde 案例源码 matlab代码程序 > pde/CreateinterpolantExample.m

    %% Create interpolant  
% This example shows how to create a |pdeInterpolant| from the solution
% to a scalar PDE.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Solve the equation $-\Delta u = 1$ on the unit disk with zero Dirichlet conditions. 
g0 = [1;0;0;1]; % circle centered at (0,0) with radius 1
sf = 'C1';
g = decsg(g0,sf,sf'); % decomposed geometry matrix
problem = allzerobc(g); % zero Dirichlet conditions
[p,e,t] = initmesh(g);
c = 1;
a = 0;
f = 1;
u = assempde(problem,p,e,t,c,a,f);  

%% 
% Construct an interpolant for the solution. 
F = pdeInterpolant(p,t,u);  

%% 
% Evaluate the interpolant at the four corners of a square. 
pOut = [0,1/2,1/2,0;
    0,0,1/2,1/2];
uOut = evaluate(F,pOut) 

%%
% The values |uOut(2)| and |uOut(4)| are nearly equal, as they should be
% for symmetric points in this symmetric problem.