Creating a New Simscape Model
Domain Types and Recommended Blocks
Simscape™ models require certain blocks to be present in the model
configuration, such as a Solver Configuration block,
or domain-specific reference blocks. Other blocks, although not required, are highly
likely to be needed, such as Simulink-PS Converter
and PS-Simulink Converter blocks. An easy way to
start a new Simscape model is by using the sscnew
function.
When you type sscnew
at the MATLAB® Command prompt, the software creates a new model prepopulated with
certain blocks.
By default, the model name is not specified, the model contains a
Solver Configuration block, a
Simulink-PS Converter block, and a
PS-Simulink Converter block connected to a
Scope block. The default solver is
VariableStepAuto
. The resources section at the bottom of the
model window provides links to the relevant block libraries and documentation
topics.
You can use the sscnew
function arguments to specify the
model name and add domain-specific blocks. See the sscnew
reference page for details. For example, typing
sscnew('pneumatic_actuator','gas')
creates the following model.
After using sscnew
, continue developing your model by copying
the blocks, as needed, and adding other blocks from the Simscape libraries.
Solver Settings for New Model
When you create a new model using sscnew
, the model has the
following settings:
Solver —
VariableStepAuto
Relative tolerance —
1e-3
Absolute tolerance —
1e-3
Auto scale absolute tolerance off
For more information, see Simulating with Variable Time Step and Choose a Solver.
Data Logging Settings for New Model
Using data logging is a best practice for Simscape models because it provides access to important simulation and analysis
tools. Therefore, the sscnew
function automatically turns on
data logging for the whole model. It uses the default workspace variable name
simlog
to store simulation data, and limits the data to the
last 10000 points to avoid slowing down simulation. At the same time, it raises
MaxDataPoints
to 10000, so that Simulink® data logging history matches Simscape data logging history.
When you create a new model using sscnew
, the model has the
following data logging configuration:
Log simulation data —
All
.Log simulation statistics — Off.
Record data in Simulation Data Inspector — Off.
Open viewer after simulation — Off.
Workspace variable name —
simlog
.Decimation —
1
.Limit data points — On.
Data history (last N steps) —
10000
.
For information on what these settings mean and how to change them, see Data Logging Options.