This example shows how to automate the setup of a Parametric Sweep by specifying the sweep parameters and their values programmatically.
Assume that we start from a file output.txt on the COMSOL Spreadsheet format which corresponds to the output of a design of experiments (DoE) study, as shown in the figure below.

The first example reads parameter values for the parameters dw and
DV from a text file. It converts each column into a space-separated string and then configures a parametric sweep for the
Sweep type option
Specified combinations. It uses the built-in
readStringMatrixFromFile method and the inserts the contents into the parametric sweep node in the current study by setting the properties
plistarr,
pname, and
punit accordingly. In this case the file
output.txt is stored in the model, under
Libraries >
Files, and is accessed using the file scheme syntax
embedded:///output.txt.
The second example reads the parameter values for the parameters dw and
DV from the same text file and formats them into the parametric sweep file format readable from the user interface. Each row is constructed as:
is used to format the numeric value in a string to a specified number of significant
digits.