Write geometry function to file
This page describes the legacy workflow. New features might not be compatible with the legacy workflow.
writes a geometry function, specified by the geometry matrix
fid = wgeom(
dl, to a
file with the name
filename.m. For information about the geometry file
format, see Parametrized Function for 2-D Geometry Creation.
Create Geometry File
Create a 2-D geometry in the PDE Modeler app, export it to the MATLAB® workspace, and then write it to a file.
Start the PDE Modeler app and draw a unit circle and a unit square.
pdecirc(0,0,1) pderect([0 1 0 1])
C1-SQ1 in the Set formula
Export the geometry description matrix, set formula, and name-space matrix to the MATLAB workspace by selecting the Export Geometry Description option from the Draw menu.
Decompose the exported geometry into minimal regions. The result is one minimal region with five edge segments: three circle edge segments and two line edge segments.
dl = decsg(gd,sf,ns)
dl = 2.0000 2.0000 1.0000 1.0000 1.0000 0 0 -1.0000 0.0000 0.0000 1.0000 0 0.0000 1.0000 -1.0000 0 1.0000 -0.0000 -1.0000 1.0000 0 0 -1.0000 0 -0.0000 0 0 1.0000 1.0000 1.0000 1.0000 1.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.0000 1.0000 1.0000
Write the resulting geometry to a file. Name the file
fid = wgeom(dl,"geometry");
dl — Decomposed geometry matrix
matrix of double-precision numbers
Decomposed geometry matrix, specified as a matrix of double-precision numbers. It
contains a representation of the decomposed geometry in terms of disjoint minimal
regions constructed by the
decsg algorithm. Each edge segment of
the minimal regions corresponds to a column in
dl. Edge segments
between minimal regions are border segments. Outer boundaries are
boundary segments. In each column, the second and third rows
contain the starting and ending x-coordinates. The fourth and fifth
rows contain the corresponding y-coordinates. The sixth and seventh
rows contain left and right minimal region labels with respect to the direction induced
by the start and end points (counterclockwise direction on circle and ellipse segments).
There are three types of possible edge segments in a minimal region:
For circle edge segments, the first row is
1. The eighth and ninth rows contain the coordinates of the center of the circle. The 10th row contains the radius.
For line edge segments, the first row is
For ellipse edge segments, the first row is
4. The eighth and ninth rows contain the coordinates of the center of the ellipse. The 10th and 11th rows contain the semiaxes of the ellipse. The 12th row contains the rotational angle of the ellipse.
All shapes in a decomposed geometry matrix have the same number of rows. Rows that are not required for a particular shape are filled with zeros.
|Row number||Circle edge segment||Line edge segment||Ellipse edge segment|
|2||starting x-coordinate||starting x-coordinate||starting x-coordinate|
|3||ending x-coordinate||ending x-coordinate||ending x-coordinate|
|4||starting y-coordinate||starting y-coordinate||starting y-coordinate|
|5||ending y-coordinate||ending y-coordinate||ending y-coordinate|
|6||left minimal region label||left minimal region label||left minimal region label|
|7||right minimal region label||right minimal region label||right minimal region label|
|8||x-coordinate of the center||x-coordinate of the center|
|9||y-coordinate of the center||y-coordinate of the center|
|10||radius of the circle||x-semiaxis before rotation|
|11||y-semiaxis before rotation|
Angle in radians between x-axis and first semiaxis
filename — Geometry file name
string | character vector
Geometry file name, specified as a string or a character vector.
fid — File identifier
File identifier, returned as an integer. If
wgeom cannot write
-1. For more information about
file identifiers, see
Introduced before R2006a