




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
This book provides an excellent initiation into programming in MATLAB while serving as a teaser for more advanced topics. It provides a structured entry into MATLAB programming through well designed exercises.
Typology: Thesis
1 / 449
This page cannot be seen from the preview
Don't miss anything!
AMSTERDAM • BOSTON • HEIDELBERG • LONDON • NEW YORK • OXFORD PARIS • SAN DIEGO • SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO Butterworth-Heinemann is an imprint of Elsevier
Butterworth-Heinemann is an imprint of Elsevier Linacre House, Jordan Hill, Oxford, OX2 8DP 30 Corporate Drive, Burlington, MA 01803
First published 2002 Reprinted 2002, 2003, 2004, 2005, 2006 Second edition 2006 Third edition 2007
Copyright © 2002, 2006, 2007 Brian D. Hahn and Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved
The right of Brian D. Hahn and Daniel T. Valentine to be identified as the authors of this work has been asserted in accordance with the Copyright, Designs and Patents Act 1988
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise without the prior written permission of the publisher
Permission may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford, UK: phone (+44) (0) 1865 843830; fax (+44) (0) 1865 853333; email: permissions@elsevier.com. Alternatively you can submit your request online by visiting the Elsevier web site at http://elsevier.com/locate/permissions, and selecting Obtaining permission to use Elsevier material
Notice No responsibility is assumed by the publisher for any injury and/or damage to persons or property as a matter of products liability, negligence or otherwise, or from any use or operation of any methods, products, instructions or ideas contained in the material herein. Because of rapid advances in the medical sciences, in particular, independent verification of diagnoses and drug dosages should be made
British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library
Library of Congress Cataloging-in-Publication Data A catalog record for this book is available from the Library of Congress
ISBN 13: 9-78-0-75-068417- ISBN 10: 0-75-068417-
For information on all Butterworth-Heinemann publications visit our web site at books.elsevier.com
Typeset by Charon Tec Ltd (A Macmillan Company), Chennai, India, www.charontec.com Printed and bound in Italy
07 08 09 10 11 10 9 8 7 6 5 4 3 2 1
In memory of Brian Hahn 1946–
Daniel T. Valentine and the staff at Butterworth-Heinemann, Elsevier would like to dedicate this book to the memory of Brian Hahn, who wrote the first edition in 1997 while he was an Associate Professor in the Department of Mathematics and Applied Mathematics, Univer- sity of Cape Town, South Africa. Brian’s academic career began after a PhD in Theoretical Physics obtained from Cambridge. His first post as Lecturer was at the University of the Witwaterstrand, Johannesburg. He was promoted to Senior Lecturer in 1979. He joined the University of Cape Town in the same year and was appointed Associate Professor in Applied Mathematics in 1991. Brian served as Head of Department for five years. He was a loved and respected teacher whose expertise in modeling and computing translated so well into the first year Applied Mathematics courses. He was the author of more than ten books on programming languages. We trust that the third edition of this book will continue to help students understand and exploit the full power of MATLAB both as a mathematical tool and as a programming language.
Preface
while on the other hand also stressing programming principles and algorithm development, with the help of structure plans.
Although most of MATLAB’s basic features are covered, the book is neither an exhaustive nor systematic reference manual, since this would not be in keeping with its informal style. Constructs, such as for and if, are not therefore always introduced in their most general form initially, as is common in many texts, but rather more gradually in the most natural places throughout the book. On the other hand, many texts present these constructs somewhat superficially; this book attempts to discuss them thoroughly. For the curious, there are helpful syntax and function quick references in the appendices.
MATLAB by its nature lends itself to a number of pitfalls for the unwary beginner. The text warns the user of these wherever possible.
The fundamentals of MATLAB are motivated throughout with many examples, from a number of different scientific and engineering areas, such as simulation, popu- lation modeling, and numerical methods, as well as from business and everyday life. Beginners, as well as experienced programmers wishing to learn MATLAB as an additional language, will therefore find plenty of interest in the book.
Emphasis is also placed on programming style throughout the book—writing clear and readable code.
Each chapter concludes with a summary of the MATLAB features introduced in the chapter.
There is a large collection of exercises at the end of each chapter, gleaned from the author’s many years’ experience of running hands-on programming courses for beginners and professionals alike, in BASIC, Pascal, C, C++ and MATLAB. Complete solutions to many of the exercises appear in an appendix.
There is a comprehensive and instructive index.
For the second edition, in working my way through Version 6, I found so many interesting new features (for example, GUIs) that I was unable to resist incorpo- rating most of them into the text. Consequently I decided to split the book into two parts. Part I contains what I consider to be the real essentials; Part II has everything else.
In this edition I have attempted to retain the style and approach of the first edition: informal, aimed at beginners, and with plenty of examples from science and engineering. Several of the chapters from the previous editions, which
xviii
Preface
feature the essential elements of MATLAB, have been brought together to form Part 1. In addition, I have added two new chapters. These are Chapters 3 and 14.
Chapter 3 describes a structured step-by-step method to achieve top-down design and algorithm development. The steps in the design process are applied in several examples. The intention is to get students thinking about how they need to formulate a problem to successfully utilize MATLAB. Chapter 14 on Dynamical Systems provides straightforward applications of the tools described and examined in the first 10 chapters. The problems solve are on relatively sim- ple dynamical systems of engineering and scientific interest. Since this book is an introductory course on MATLAB, a tool for technical computing, the exam- ples are mathematical formulations of problems from first courses in science and engineering. The purpose of the text is to provide instruction on how to solve the mathematical problems needed to gain insight into science and engi- neering. Thus, these eleven chapters (skipping over the sections marked with an asterisk) are sufficient for a first course in MATLAB. (For the computer and programming-calculator wise students, the chapters on more advanced topics should help them get into the application of MATLAB to solve the more complex problems confronted in upper division courses at university and, subsequently, on the job.)
This book can be used as a course textbook or for student self-study. For the latter, it is a useful supplemental text for any course in science and engineering. The instructor, of course, provides the necessary encouragement, enthusiasm and guidance to help the student begin to learn the power of MATLAB to solve numerous problems that engineers and scientists formulate in terms of math- ematics and, hence, help the student begin to master MATLAB. The book is written as a sequence of exercises, and the reader would benefit from doing the exercises within the text as well as doing some of the exercises at the end of the chapters.
To the student: I recommend that you read the text while you are at your com- puter so that you can do the exercises with MATLAB. It will be useful and fun for you to go through the exercises with the purpose of discovering how MATLAB does what it is commanded by you to do. You learn how to use a tool like MAT- LAB through hands-on experience. This, of course, is a good thing because it is quite pleasurable to learn by doing and, hence, discover how to use MATLAB to enhance your learning of engineering and science by tapping the wealth of capa- bility at your disposal in MATLAB. You will discover immediately that computer tools produce correct answers only when commands and input data are accu- rate and correct (no typographical errors are tolerated). ‘Debugging’—finding the errors in your typed command lines—is a big part of the game that is played
xix