Book Image

Getting Started with Simulink

By : Luca Zamboni
Book Image

Getting Started with Simulink

By: Luca Zamboni

Overview of this book

Simulink is an engineer's Swiss army knife: instead of spending the day typing out complex formulas, Simulink enables you to both draw and execute them. Block after block, you can develop your ideas without struggling with obscure programming languages and you don't have to wait to debug your algorithm - just launch a simulation! Getting Started with Simulink will give you comprehensive knowledge of Simulink's capabilities. From the humble constant block to the S-function block, you will have a clear understanding of what modelling really means, without feeling that something has been left out. By the time you close the book, you'll be able to further extend your modelling skills without any help. We''ll start with a brief introduction, and immediately start placing the first blocks. Little by little, you'll build a car cruise controller model, followed by the mathematical model of a sports car in order to calibrate it. Then you'll learn how to interface your Simulink model with the external world. This book will give you an easy understanding of the tools Simulink offers you, guiding you through a complex exercise split into the three main phases of Simulink development: modelling, testing, and interfacing.
Table of Contents (11 chapters)

The mandatory theory


Before starting the simulation, we'll have a closer look at how Simulink computes the simulation results, in order to be able to choose the appropriate simulation time and solver.

Let's build a simple system that finds the solution to this problem:

The exact mathematical solution is y(t) = e -t.

The Simulink model (which we'll save as example.slx) that implements the problem is:

Notice that we've set the Initial condition source parameter of the Integrator block to be external.

To configure the simulation time and solver of this model, click on the Model Configuration Parameters option from the Simulation menu (keyboard shortcut: Ctrl + E).

A new window will open; select the Solver node from the left-side panel, which will give you access to configure the Solver options and Simulation time parameters.

Under the Solver options section, select the Type list value as Fixed-step (don't worry, we'll explain the meaning later) as shown in the following screenshot:

Then let's edit...