Introduction

The Simulink is a multi-domain tool used for simulation and design based in block diagrams of dynamical and embedded systems. The Simulink can also be used to simulate and implement control systems, signal processing and other time-varying systems.

Initiating Simulink

The video below shows how to start from within Matlab the Simulink and also create a simple model. This model takes a sine signal and applies a 5x gain and derive the result, the result of this operation will be passed to a Scope block to view. The video also shows how to rename blocks and signals in the diagram.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Exchanging data between Simulink and Matlab Workspace

In Simulink all workspace variables in Matlab are visible to the Simulink model, for example you can define a variable "A = 5" in Matlab and access the variable from within Simulink model, in turn if you change the value of the variable Matlab workspace of this change is propagated to the Simulink.

How Simulink Works

The Simulink propagates signals in time by calculating a numerical approximation of each block every clock cycle. This clock pulse sets the resolution of the simulation.The Simulink module that calculate this aproximation of each block is called "solver". By the standard Simulink automatically calculates the step based on the "stop time" simulation. Consider a diagram that implements the following function, with "tstop" of 10 units time:

Now let's redo the simulation with "tstop" of 50 units of time.

Note that the resolution of the simulation has become very poor, because the Simulink calculates the step with the "auto" parameter as follows:

In other words, the greater tstop greater the "step size", making the simulation with less resolution. To solve this problem we have to configure Simulink withe the "step size" fixed, the only problem is if you choose a "tstop" very large, for the Simulink have to simulate a mass of data much larger. The video below shows how to configure Simulink to take a "step size" of up to 0.2.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Obtaining help in Simulink

Just click "Help->Using Simulink", if you want some help about a block just select it and press F1

Creating a "if" operation inside a model

In this model we show how to use the block "switch" to route a signal in a logical condition, in this case we will use the "time" as a condition variable. This block is in the Library Browser "Simulink->Signal Routing".

Using signals from Matlab

We shall see how to use input signals coming from Matlab workspace with the block "From Workspace" in the library "Simulink-> Sources", the advantage of using this block is that we can use signals generated synthetically or imported from Matlab.

An important detail to notice is that the array that being pointed by Simulink need two columns, one for another time and the signal itself.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Creating Subsystems and Masks

As model increase its size, also increases its complexity, so it is important to make it modular, separating a set of blocks into sub-systems, thus, this set of blocks becomes a "super block", with all its logic encapsulated. To create a subsystem just select the block, clicking the right - "Create Subsystem"

The masks are used to create a custom block from a Subsystem, them you can change all parameters of the blocks contained in the sub-system.
The video below will show how to create sub-systems and masks.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Next topics