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

    %% Geometry from Decomposed Solid Geometry
% Create a decomposed solid geometry model and include it in a PDE model.
%%
% Create a default scalar PDE model.
model = createpde;
%%
% Define a circle in a rectangle, place these in one matrix, and create a
% set formula that subtracts the circle from the rectangle.
R1 = [3,4,-1,1,1,-1,0.5,0.5,-0.75,-0.75]';
C1 = [1,0.5,-0.25,0.25]';
C1 = [C1;zeros(length(R1) - length(C1),1)];
gm = [R1,C1];
sf = 'R1-C1';
%%
% Create the geometry.
ns = char('R1','C1');
ns = ns';
g = decsg(gm,sf,ns);
%%
% Include the geometry in the model and plot it.
geometryFromEdges(model,g);
pdegplot(model,'EdgeLabels','on')
axis equal
xlim([-1.1,1.1])