xii Contents Glossary 299 MATLAB Operators 300 Built-in Constants 301 Built-in Functions 302 MATLAB Commands 303 Graphics Commands 309 MATLAB Programming 313 Index 317 indicates an advanced chapter or section that can be skipped on a first reading
xii Contents Glossary 299 MATLAB Operators 300 Built-in Constants 301 Built-in Functions 302 MATLAB Commands 303 Graphics Commands 309 MATLAB Programming 313 Index 317 indicates an advanced chapter or section that can be skipped on a first reading.
Preface MATLAB is an integrated technical computing environment that combines numeric computation,advanced graphics and visualization,and a high- level programming language. -www.mathworks.com/products/matlab That statement encapsulates the view of The Math Works,Inc.,the developer of MATLAB.MATLAB 6 is an ambitious program.It contains hundreds of com- mands to do mathematics.You can use it to graph functions,solve equations, perform statistical tests,and do much more.It is a high-level programming language that can communicate with its cousins,e.g.,FORTRAN and C.You can produce sound and animate graphics.You can do simulations and mod- eling (especially if you have access not just to basic MATLAB but also to its accessory SIMULINK).You can prepare materials for export to the World Wide Web.In addition,you can use MATLAB,in conjunction with the word processing and desktop publishing features of Microsoft Word,to combine mathematical computations with text and graphics to produce a polished,in- tegrated,and interactive document. A program this sophisticated contains many features and options.There are literally hundreds of useful commands at your disposal.The MATLAB help documentation contains thousands of entries.The standard references, whether the Math Works User's Guide for the product,or any of our com- petitors,contain myriad tables describing an endless stream of commands, options,and features that the user might be expected to learn or access. MATLAB is more than a fancy calculator;it is an extremely useful and versatile tool.Even if you only know a little about MATLAB,you can use it to accomplish wonderful things.The hard part,however,is figuring out which of the hundreds of commands,scores of help pages,and thousands of items of documentation you need to look at to start using it quickly and effectively. That's where we come in. xili
Preface MATLAB is an integrated technical computing environment that combines numeric computation, advanced graphics and visualization, and a highlevel programming language. – www.mathworks.com/products/matlab That statement encapsulates the view of The MathWorks, Inc., the developer of MATLAB. MATLAB 6 is an ambitious program. It contains hundreds of commands to do mathematics. You can use it to graph functions, solve equations, perform statistical tests, and do much more. It is a high-level programming language that can communicate with its cousins, e.g., FORTRAN and C. You can produce sound and animate graphics. You can do simulations and modeling (especially if you have access not just to basic MATLAB but also to its accessory SIMULINK). You can prepare materials for export to the World Wide Web. In addition, you can use MATLAB, in conjunction withthe word processing and desktop publishing features of Microsoft Word, to combine mathematical computations with text and graphics to produce a polished, integrated, and interactive document. A program this sophisticated contains many features and options. There are literally hundreds of useful commands at your disposal. The MATLAB help documentation contains thousands of entries. The standard references, whether the MathWorks User’s Guide for the product, or any of our competitors, contain myriad tables describing an endless stream of commands, options, and features that the user might be expected to learn or access. MATLAB is more than a fancy calculator; it is an extremely useful and versatile tool. Even if you only know a little about MATLAB, you can use it to accomplish wonderful things. The hard part, however, is figuring out which of the hundreds of commands, scores of help pages, and thousands of items of documentation you need to look at to start using it quickly and effectively. That’s where we come in. xiii
xiv Preface Why We Wrote This Book The goal of this book is to get you started using MATLAB successfully and quickly.We point out the parts of MATLAB you need to know without over- whelming you with details.We help you avoid the rough spots.We give you examples of real uses of MATLAB that you can refer to when you're doing your own work.And we provide a handy reference to the most useful features of MATLAB.When you're finished reading this book,you will be able to use MATLAB effectively.You'll also be ready to explore more of MATLAB on your own. You might not be a MATLAB expert when you finish this book,but you will be prepared to become one-if that's what you want.We figure you're probably more interested in being an expert at your own specialty,whether that's finance,physics,psychology,or engineering.You want to use MATLAB the way we do,as a tool.This book is designed to help you become a proficient MATLAB user as quickly as possible,so you can get on with the business at hand. Who Should Read This Book This book will be useful to complete novices,occasional users who want to sharpen their skills,intermediate or experienced users who want to learn about the new features of MATLAB 6 or who want to learn how to use SIMULINK,and even experts who want to find out whether we know any- thing they don't. You can read through this guide to learn MATLAB on your own.If your employer(or your professor)has plopped you in front of a computer with MATLAB and told you to learn how to use it,then you'll find the book par- ticularly useful.If you are teaching or taking a course in which you want to use MATLAB as a tool to explore another subject-whether in mathematics, science,engineering,business,or statistics-this book will make a perfect supplement. As mentioned,we wrote this guide for use with MATLAB 6.If you plan to continue using MATLAB 5,however,you can still profit from this book. Virtually all of the material on MATLAB commands in this book applies to both versions.Only a small amount of material on the MATLAB interface, found mainly in Chapters 1,3,and 8,is exclusive to MATLAB 6
xiv Preface Why We Wrote This Book The goal of this book is to get you started using MATLAB successfully and quickly. We point out the parts of MATLAB you need to know without overwhelming you with details. We help you avoid the rough spots. We give you examples of real uses of MATLAB that you can refer to when you’re doing your own work. And we provide a handy reference to the most useful features of MATLAB. When you’re finished reading this book, you will be able to use MATLAB effectively. You’ll also be ready to explore more of MATLAB on your own. You might not be a MATLAB expert when you finish this book, but you will be prepared to become one — if that’s what you want. We figure you’re probably more interested in being an expert at your own specialty, whether that’s finance, physics, psychology, or engineering. You want to use MATLAB the way we do, as a tool. This book is designed to help you become a proficient MATLAB user as quickly as possible, so you can get on withthe business at hand. Who Should Read This Book This book will be useful to complete novices, occasional users who want to sharpen their skills, intermediate or experienced users who want to learn about the new features of MATLAB 6 or who want to learn how to use SIMULINK, and even experts who want to find out whether we know anything they don’t. You can read through this guide to learn MATLAB on your own. If your employer (or your professor) has plopped you in front of a computer with MATLAB and told you to learn how to use it, then you’ll find the book particularly useful. If you are teaching or taking a course in which you want to use MATLAB as a tool to explore another subject — whether in mathematics, science, engineering, business, or statistics — this book will make a perfect supplement. As mentioned, we wrote this guide for use with MATLAB 6. If you plan to continue using MATLAB 5, however, you can still profit from this book. Virtually all of the material on MATLAB commands in this book applies to bothversions. Only a small amount of material on the MATLAB interface, found mainly in Chapters 1, 3, and 8, is exclusive to MATLAB 6
Preface XV How This Book Is Organized In writing,we drew on our experience to provide important information as quickly as possible.The book contains a short,focused introduction to MATLAB.It contains practice problems(with complete solutions)so you can test your knowledge.There are several illuminating sample projects that show you how MATLAB can be used in real-world applications,and there is an en- tire chapter on troubleshooting. The core of this book consists of about 75 pages:Chapters 1-4 and the begin- ning of Chapter 5.Read that much and you'll have a good grasp of the funda- mentals of MATLAB.Read the rest-the remainder of the Graphics chapter as well as the chapters on M-Books,Programming,SIMULINK and GUIs,Ap- plications,MATLAB and the Internet,Troubleshooting,and the Glossary- and you'll know enough to do a great deal with MATLAB. Here is a detailed summary of the contents of the book. Chapter 1,Getting Started,describes how to start MATLAB on different platforms.It tells you how to enter commands,how to access online help,how to recognize the various MATLAB windows you will encounter,and how to exit the application. Chapter 2,MATLAB Basics,shows you how to do elementary mathe- matics using MATLAB.This chapter contains the most essential MATLAB commands. Chapter 3,Interacting with MATLAB,contains an introduction to the MATLAB Desktop interface.This chapter will introduce you to the basic window features of the application,to the small program files(M-files)that you will use to make most effective use of the software,and to a simple method (diary files)of documenting your MATLAB sessions.After completing this chapter,you'll have a better appreciation of the breadth described in the quote that opens this preface. Practice Set A,Algebra and Arithmetic,contains some simple problems for practicing your newly acquired MATLAB skills.Solutions are presented at the end of the book. Chapter 4,Beyond the Basics,contains an explanation of the finer points that are essential for using MATLAB effectively. Chapter 5,MATLAB Graphics,contains a more detailed look at many of the MATLAB commands for producing graphics. Practice Set B,Calculus,Graphics,and Linear Algebra,gives you another chance to practice what you've just learned.As before,solutions are provided at the end of the book
Preface xv How This Book Is Organized In writing, we drew on our experience to provide important information as quickly as possible. The book contains a short, focused introduction to MATLAB. It contains practice problems (withcomplete solutions) so you can test your knowledge. There are several illuminating sample projects that show you how MATLAB can be used in real-world applications, and there is an entire chapter on troubleshooting. The core of this book consists of about 75 pages: Chapters 1–4 and the beginning of Chapter 5. Read that much and you’ll have a good grasp of the fundamentals of MATLAB. Read the rest — the remainder of the Graphics chapter as well as the chapters on M-Books, Programming, SIMULINK and GUIs, Applications, MATLAB and the Internet, Troubleshooting, and the Glossary — and you’ll know enoughto do a great deal withMATLAB. Here is a detailed summary of the contents of the book. Chapter 1, Getting Started, describes how to start MATLAB on different platforms. It tells you how to enter commands, how to access online help, how to recognize the various MATLAB windows you will encounter, and how to exit the application. Chapter 2, MATLABBasics, shows you how to do elementary mathematics using MATLAB. This chapter contains the most essential MATLAB commands. Chapter 3, Interacting with MATLAB, contains an introduction to the MATLAB Desktop interface. This chapter will introduce you to the basic window features of the application, to the small program files (M-files) that you will use to make most effective use of the software, and to a simple method (diary files) of documenting your MATLAB sessions. After completing this chapter, you’ll have a better appreciation of the breadth described in the quote that opens this preface. Practice Set A, Algebra and Arithmetic, contains some simple problems for practicing your newly acquired MATLAB skills. Solutions are presented at the end of the book. Chapter 4, Beyond the Basics, contains an explanation of the finer points that are essential for using MATLAB effectively. Chapter 5, MATLABGraphics, contains a more detailed look at many of the MATLAB commands for producing graphics. Practice Set B, Calculus, Graphics, and Linear Algebra, gives you another chance to practice what you’ve just learned. As before, solutions are provided at the end of the book
xvi Preface Chapter 6,M-Books,contains an introduction to the word processing and desktop publishing features available when you combine MATLAB with Microsoft Word. Chapter 7,MATLAB Programming,introduces you to the programming features of MATLAB.This chapter is designed to be useful both to the novice programmer and to the experienced FORTRAN or C programmer. Chapter 8,SIMULINK and GUIs,consists of two parts.The first part de- scribes the MATLAB companion software SIMULINK,a graphically oriented package for modeling,simulating,and analyzing dynamical systems.Many of the calculations that can be done with MATLAB can be done equally well with SIMULINK.If you don't have access to SIMULINK,skip this part of Chapter 8.The second part contains an introduction to the construction and deployment of graphical user interfaces,that is,GUIs,using MATLAB. Chapter 9,Applications,contains examples,from many different fields,of solutions of real-world problems using MATLAB and/or SIMULINK. Practice Set C,Developing Your MATLAB Skills,contains practice problems whose solutions use the methods and techniques you learned in Chapters 6-9. Chapter 10,MATLAB and the Internet,gives tips on how to post MATLAB output on the Web. Chapter 11,Troubleshooting,is the place to turn when anything goes wrong. Many common problems can be resolved by reading(and rereading)the advice in this chapter. Next,we have Solutions to the Practice Sets,which contains solutions to all the problems from the three practice sets.The Glossary contains short de- scriptions(with examples)of many MATLAB commands and objects.Though not a complete reference,it is a handy guide to the most important features of MATLAB.Finally,there is a complete Index. Conventions Used in This Book We use distinct fonts to distinguish various entities.When new terms are first introduced,they are typeset in an italic font.Output from MATLAB is typeset in a monospaced typewriter font;commands that you type for interpretation by MATLAB are indicated by a boldface version of that font. These commands and responses are often displayed on separate lines as they would be in a MATLAB session,as in the following example: >>x=8qrt(2*pi+1) 2.697
xvi Preface Chapter 6, M-Books, contains an introduction to the word processing and desktop publishing features available when you combine MATLAB with Microsoft Word. Chapter 7, MATLABProgramming, introduces you to the programming features of MATLAB. This chapter is designed to be useful both to the novice programmer and to the experienced FORTRAN or C programmer. Chapter 8, SIMULINK and GUIs, consists of two parts. The first part describes the MATLAB companion software SIMULINK, a graphically oriented package for modeling, simulating, and analyzing dynamical systems. Many of the calculations that can be done with MATLAB can be done equally well with SIMULINK. If you don’t have access to SIMULINK, skip this part of Chapter 8. The second part contains an introduction to the construction and deployment of graphical user interfaces, that is, GUIs, using MATLAB. Chapter 9, Applications, contains examples, from many different fields, of solutions of real-world problems using MATLAB and/or SIMULINK. Practice Set C, Developing Your MATLABSkills, contains practice problems whose solutions use the methods and techniques you learned in Chapters 6–9. Chapter 10, MATLABand the Internet, gives tips on how to post MATLAB output on the Web. Chapter 11, Troubleshooting, is the place to turn when anything goes wrong. Many common problems can be resolved by reading (and rereading) the advice in this chapter. Next, we have Solutions to the Practice Sets, which contains solutions to all the problems from the three practice sets. The Glossary contains short descriptions (withexamples) of many MATLAB commands and objects. Though not a complete reference, it is a handy guide to the most important features of MATLAB. Finally, there is a complete Index. Conventions Used in This Book We use distinct fonts to distinguishvarious entities. When new terms are first introduced, they are typeset in an italic font. Output from MATLAB is typeset in a monospaced typewriter font; commands that you type for interpretation by MATLAB are indicated by a boldface version of that font. These commands and responses are often displayed on separate lines as they would be in a MATLAB session, as in the following example: >> x = sqrt(2*pi + 1) x = 2.697