Main Content

Model System Algorithm

When incomplete system requirements and a developing system design prevent you from defining file management and model architecture upfront, you can still model fundamental system algorithms. By organizing the model into inputs, outputs, and systems, you create a general framework for model components as the model grows.

To show the first stage of a modeling workflow that begins with limited information, this example uses a simple mechanical system composed of a mass, spring, and damper.

Diagram of simple mass, spring, and damper system

This second-order differential equation characterizes the system.

mx¨+cx˙+kx=F

In this equation:

  • m is mass.

  • c is the damping coefficient.

  • k is the spring constant.

  • x¨ is acceleration.

  • x˙ is velocity.

  • x is displacement.

  • F is external force.

Solving for x¨ provides a form of this equation that maps more clearly to a Simulink® model.

x¨=1m(F-cx˙-kx)

The model named BasicModelingSimpleSystem represents this equation.

mdl = "BasicModelingSimpleSystem";
open_system(mdl);

Model with areas labeled Sources, System, and Sinks

A Sum block computes the net force applied to the mass. The Gain block labeled 1/m computes the acceleration of the mass by multiplying the net force by 1/m. The Integrator, Second-Order block solves for the velocity and position of the mass.

The model organizes the blocks into three areas:

  • The area named Sources contains system inputs.

  • The area named System contains blocks that represent the system, or plant.

  • The area named Sinks contains system outputs.

By organizing the model upfront, you create a general framework for model components as the model grows.

Because this example shows a model in the preliminary stages of development, the actual input force is unknown and can be represented by a variety of standard source blocks. The model uses a Step block connected as input to the system. Some alternative source blocks are shown but commented out. For example, you can use the From Spreadsheet block to load available empirical data.

Similarly, a variety of sink blocks can accept the output displacement. To check whether simulation results meet expectations, the model uses a Scope block to visualize the signals.

sim(mdl);

Simulation results in Scope window

Related Topics