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)

Our first model – a cruise controller


There aren't many things in the world funnier than a sporty car. That's a fact.

Let's imagine we want to develop a simple cruise control system for such a car. This system will perform the following tasks:

  • Read the target vehicle speed [km/h]

  • Read the current vehicle speed [km/h]

  • Command the throttle with the gas pedal [from 0 (not pressed) to 1 (fully pressed)]

This system will behave like a driver that keeps the car going straight using only the gas pedal to match the desired speed.

Let's get started!

Step 1 – create and save the model

After pointing MATLAB to your preferred working folder (for example, a folder called 1386EN_02 located in your home folder) and opening a new model, click on the Save button, or use the Save option under the File menu, or the Ctrl + S keyboard shortcut, and give it the name cruise_control.slx.

You'll notice that there are two file formats available. They are explained as follows:

  • The .mdl extension was the format used by Simulink...