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

    %% Assemble Finite Element Matrices for a 2-D Problem With Boundary Conditions Imposed Using |nullspace| Method and Obtain PDE Solution
% Create a PDEModel for the Poisson equation on the L-shaped membrane with zero Dirichlet boundary conditions. 
model = createpde(1);
geometryFromEdges(model,@lshapeg);
specifyCoefficients(model,'m',0,'d',0,'c',1,'a',0,'f',1);
applyBoundaryCondition(model,'edge',1:model.Geometry.NumEdges,'u',0);
%%
% Generate a mesh and obtain the |nullspace| finite element matrices for
% the problem and mesh.
generateMesh(model,'Hmax',0.2);
FEM = assembleFEMatrices(model,'nullspace')
%%
% Obtain the solution to the PDE.
u = FEM.B*(FEM.Kc\FEM.Fc) + FEM.ud;
%%
% Compare to the solution using |solvepde|. The two solutions are
% identical.
u1 = solvepde(model);
norm(u - u1.NodalSolution)