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)

Preface

This book will give you a complete understanding of the Simulink software. You will learn by example, going through the three main phases of Simulink development—modeling, simulating, and interfacing with the external world while developing a cruise controller for a real car.

While reading this book, you'll be given a clear, no-frills explanation of the main components of Simulink and how to use them in order to achieve the desired result. After having read this book, you will be able to develop, test, and deploy your models without any difficulty.

What this book covers

Chapter 1, Simulink Facts, deals with the problems that arise while developing the software for the biggest manufacturing industries and how Simulink can cut down the total development time, from specifications to final implementation. You will understand where Simulink really shines and where it isn't worth the hassle.

Chapter 2, Creating a Model, deals with developing a very simple cruise controller model in order to get started quickly with Simulink and the MATLAB environment. Then you will be guided through the Simulink implementation of a real-world car to use with the previously developed cruise controller, thus introducing the usage of more complex blocks. You will understand how a model is developed and where to look for the appropriate blocks.

Chapter 3, Simulating a Model, deals with presenting the theory behind simulation: solvers, simulation times, and how to choose them. You will then simulate the models you already developed, learning what are the available sources and sinks blocks and when to use them in order to discover failures in your models and change some of the parameters you defined.

Chapter 4, Using the Model, guides you through the most powerful feature of Simulink—the ability to create your own blocks, also known as S-function development—after having learned how to develop and simulate a model. You will create a simple S-function that enables your cruise controller to drive an external application and receive feedback from it.

What you need for this book

You should have a working MATLAB installation with the Simulink package. While this book has been written using the 8.1 (R2013a) release, you aren't required to use this exact version, as there are only minor differences between one release and another; the basic workflow remains the same. But you'll need at least the 8.1 release to be able to run the provided code.

In order to develop and test S-functions, you should have a compiler supported by your MATLAB release.

Who this book is for

This book is aimed at undergraduate students, researchers, and engineers who need to have a quick and complete understanding of how Simulink works, including some of its most advanced features.

The reader should have basic knowledge of physics and C programming.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: While, to a certain degree, it is possible to spot the differences when saving models with the .mdl format.

A block of code is set as follows:

  int main()
{
  int u1, u2, y1;
  printf(""Enter two numbers\n"");
  scanf(""%d%d"", &u1, &u2);
  y1 = mul(u1, u2);
  printf(""Here''s your result,the operation done is a shining ''x''!\n%d\n"", y1);
     return EXIT_SUCCESS;
}

Any command-line input or output is written as follows:

  new_string = 'hello world!';
  new_number = 0.01;

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "From the MATLAB main window, click on the New button and select the Simulink Model option".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.