www.gusucode.com > pde 案例源码 matlab代码程序 > pde/FiniteElementMatricesExample.m
%% Finite Element Matrices % Obtain the finite-element matrices that represent the problem using a % reduced linear algebra representation of Dirichlet boundary conditions. %% % Create a scalar PDE model. Import a simple 3-D geometry. model = createpde; importGeometry(model,'Block.stl'); %% % Set zero Dirichlet boundary conditions on all the geometry faces. applyBoundaryCondition(model,'dirichlet','Face',1:model.Geometry.NumFaces,'u',0); %% % Generate a mesh for the geometry. generateMesh(model); %% % Obtain finite element matrices |K|, |F|, |B|, and |ud| that represent the % equation $- \nabla \cdot \left( c \nabla u \right) + au = f$ with % parameters $c = 1$, $a = 0$, and $f = \log \left(1 + x + \frac{y}{1 + z} % \right)$. c = 1; a = 0; f = 'log(1+x+y./(1+z))'; [K,F,B,ud] = assempde(model,c,a,f); %% % You can obtain the solution |u| of the PDE at mesh nodes by executing the % command u = B*(K\F) + ud; %% % Generally, this solution is slightly more accurate than the stiff-spring % solution, as calculated in the next example.