model.func().create(<tag>,<type>) creates a new function of type
<type> with the tag
<tag>. The types can be one of the following strings:
Analytic,
Elevation,
External,
Image,
Interpolation,
MATLAB (requires LiveLink™
for MATLAB®),
Piecewise,
GaussianPulse,
Ramp,
Random,
Rectangle,
Step,
Triangle, and
Wave. In addition,
model.create(<tag>,"FunctionSwitch") creates a function switch. You can add other functions to a function switch:
model.func(<tag>).createPlot(<pgtag>) creates a plot group with the tag
pgtag with a plot of the function. The method returns the plot group.
model.func(<tag>).label(
<label>) sets a label for the function.
model.func(<tag>).model(<mtag>) sets the model component node of the function.
model.func(<tag>).set(property,<value>) sets the value of a property of the function. See the available properties for each type of function below.
model.func(<tag>).set("funcname",<funcname>) sets the operator name of the function. The default operator name is
<tag>.
model.func(<tag>).model() returns the model component node tag.
model.func(<tag>).getType(property) retrieves a value of a function property.
model.func(<tag>).importData() imports the file that the function references into the model. This is possible for interpolation, elevation, and image functions. The
importData() method also works for some physics features.
model.func(<tag>).discardData() discards the data imported with
importData(). This is possible for interpolation, elevation, and image functions. The
discardData() method also works for some physics features.
model.func(<tag>).refresh() reevaluates the file for functions that read files (Elevation, Image, and Interpolation).
Use the model.func(<tag>).image() methods for plotting and exporting images showing plots of the functions. See
Plotting and Exporting Images.
model.func(<tag>).functionNames() returns an array containing the function names that the function feature defines. Most functions always return an array of length one, but interpolation function features, for example, can define an arbitrary number of function names.
model.func(<tag>).getAllowedPropertyValues(property) returns the set of allowed values for a property if the set is a finite set of strings; otherwise, it returns null.
Generate an analytic function using a symbolic expression.
Generate an interpolation function. You can use several interpolation and extrapolation methods..
Generate a piecewise interpolation function, which is created by splicing together several functions, each defined on one interval.
Generate a Gaussian pulse function. This function is the common bell-shaped curve (Gaussian function).
Generate a random function. The random function can have a uniform or normal distribution.
Generate an external function that interfaces to other external functions written in the C language.
If the arguments are all-real, then inImag is null; otherwise it contains the imaginary parts of the arguments. If the function evaluation is successful, 1 is returned if it resulted in an all-real array and 2 is returned if it resulted in a complex array. The function should return 0 in case of error. In case of a real result, the function values should be written to the array
outReal. In case of a complex result, the real parts of the function should be written to
outReal and the imaginary parts to
outImag. The
outReal and
outImag arrays both have length
blockSize. All matrices are allocated and deallocated by COMSOL.
To compile this function into a library, place it in ext.c and proceed as follows depending on platform:
Generate an elevation function by importing geospatial elevation data from digital elevation models (DEM files).
Generate an image function from a BMP, GIF, JPEG, or PNG file.
Declare use of function in MATLAB. This requires the LiveLink™
for MATLAB®.
Use a wave function to generate a wave-shaped function. The wave shape can be a sawtooth, sine wave, square wave, or triangle wave.