Main Content

Essential Steps for Constructing a Physical Model

Workflow Overview

The table lists the essential major steps for building and simulating a physical model, along with related documentation topics that provide background information on each step. Detailed step descriptions follow.

The graphic illustrates the key workflow steps as applied to the Mass-Spring-Damper with Controller example model. Step descriptions below include detailed instructions on how to create this model.

Step 1: Create New Model Using ssc_new

Using ssc_new is the best way to start building Simscape™ models. It helps to ensure that you use recommended default settings for your model. When you use ssc_new, it automatically:

  • Creates a new Simscape model, with required and commonly used blocks already on the model canvas

  • Selects recommended solver and tolerance settings

  • Enables data logging for the whole model

 Detailed Instructions

Step 2: Assemble Physical Network

To model your system, you add blocks from the Simscape libraries to a model, and then connect them into a physical network. The lines connecting the blocks in the schematic you create represent the physical connections that exist between the components in a real system that you are modeling. In other words, Simscape diagrams mimic the physical system layout.

When constructing your network, it is important to include domain-specific reference blocks, such as Electrical Reference, Mechanical Translational Reference, and so on. Depending on domain, these blocks represent connection to ground, frame, or atmosphere. For more information, see Grounding Rules.

 Detailed Instructions

Step 3: Adjust Block Parameters and Variable Targets

Simscape blocks represent generic components that have default initial values for block parameters and variables. You can adjust these values to suit your application or match the manufacturer data sheet.

To view and modify the block parameter values and initialization targets for the block variables, double-click the block to open its dialog box. Use the Settings tab.

For most of the Simscape blocks, the block dialog box contains the same information and has the same layout as the block Property Inspector. By default, changing a value in the Property Inspector immediately applies the new value. For better control, it is recommended that you clear the Auto Apply check box in the upper-right corner of the block dialog box to enable the Reset and Apply buttons. This is especially helpful when working with complex blocks, where you change multiple parameters at once. Change the parameter values to match the manufacturer data sheet, review the whole set, and then click Apply. Clearing the Auto Apply check box persists for the duration of your MATLAB session.

To view the description of a block, click the Description tab in the block dialog box. This tab also contains the Source code link. Click this link to open the Simscape source file for this block in the MATLAB Editor.

If a block has no parameters or variable targets that can be set, then the block dialog box does not have a Settings tab, only a Description tab.

To view the documentation for a block, click the Question Mark Question mark button in the upper-right corner of the block dialog box.

 Detailed Instructions

Step 4: Add Sources

You can drive Simscape models using input signals. This technique allows you to represent physical effects, such as forces, voltages, or pressures, that act on your system. You can also specify other quantities that flow through your system, such as current, mass flow rate, and heat flux. You add signal input connections to your physical network by using Simscape source blocks.

 Detailed Instructions

Step 5: Add Sensors

You can measure quantities from your physical network and use them in other locations in your model. Some common uses of those quantities include feedback for a control algorithm, modeling physical components whose behavior depends on other physical quantities (such as temperature-dependent resistor), or simply viewing the results during simulation.

You measure quantities using sensor blocks, connected in series or in parallel depending on the measured value. To measure a quantity defined by a Through variable (such as current, flow rate, force), connect the sensor in series. To measure a quantity defined by an Across variable (such as voltage, pressure, velocity), connect the sensor in parallel. For more information on Through and Across variables, see Variable Types.

 Detailed Instructions

Step 6: Connect to Simulink with Interface Blocks

Equations in a Simscape network are solved simultaneously, while Simulink blocks are evaluated sequentially. Interface blocks, such as Simulink-PS Converter and PS-Simulink Converter, handle the boundary between these two modeling conventions. You need interface blocks when Simulink signals specify quantities in a Simscape network, or when passing Simscape quantities to Simulink for control design or other purposes. Every time you connect a Simulink block to a Simscape physical network, you have to use an appropriate converter block.

 Detailed Instructions

Step 7: Simulate Model

You run simulations by clicking the Run button in the Simulink Toolstrip (at the top of the model window) or in a Scope Viewer toolbar. The Simscape solver evaluates the model, calculates the initial conditions, and runs the simulation. For a detailed description of this process, see How Simscape Simulation Works. The message in the bottom-left corner of the model window provides the status update.

 Detailed Instructions

Step 8: View Simulation Results

The Simscape Results Explorer lets you view and analyze simulation data by using the data logging functionality. For example, you can compare two simulation runs to analyze how changing the mass affects the spring deformation.

 Detailed Instructions