MATLAB: A Practical Introduction to Programming and Problem Solving (5th Edition) PDF
MATLAB: A Practical Introduction to Programming and Problem Solving (5th Edition) PDF
com
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
MATLAB®
A Practical Introduction to Programming
and Problem Solving
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
®
MATLAB
A Practical Introduction to Programming
and Problem Solving
Fifth Edition
Stormy Attaway
Department of Mechanical Engineering
Boston University
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
No part of this publication may be reproduced or transmitted in any form or by any means, electronic or
mechanical, including photocopying, recording, or any information storage and retrieval system, without
permission in writing from the publisher. Details on how to seek permission, further information about the
Publisher’s permissions policies and our arrangements with organizations such as the Copyright Clearance
Center and the Copyright Licensing Agency, can be found at our website: www.elsevier.com/permissions.
This book and the individual contributions contained in it are protected under copyright by the Publisher
(other than as may be noted herein).
Notices
Knowledge and best practice in this field are constantly changing. As new research and experience
broaden our understanding, changes in research methods, professional practices, or medical treatment may
become necessary.
Practitioners and researchers must always rely on their own experience and knowledge in evaluating and
using any information, methods, compounds, or experiments described herein. In using such information or
methods they should be mindful of their own safety and the safety of others, including parties for whom they
have a professional responsibility.
To the fullest extent of the law, neither the Publisher nor the authors, contributors, or editors, assume any
liability 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.
MATLAB® is a registered trademark of The MathWorks, Inc., and is used with permission.
ISBN: 978-0-12-815479-3
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
Dedication
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
Preface
MOTIVATION
The purpose of this book is to teach basic programming concepts and skills
needed for basic problem solving, all using MATLAB® as the vehicle. MATLAB
is a powerful software package that has built-in functions to accomplish a
diverse range of tasks, from mathematical operations to three-dimensional
imaging. Additionally, MATLAB has a complete set of programming constructs
that allows users to customize programs to their own specifications.
There are many books that introduce MATLAB. There are two basic flavors of
these books: those that demonstrate the use of the built-in functions in
MATLAB, with a chapter or two on some programming concepts, and those that
cover only the programming constructs without mentioning many of the built-
in functions that make MATLAB efficient to use. Someone who learns just the
built-in functions will be well-prepared to use MATLAB, but would not under-
stand basic programming concepts. That person would not be able to then
learn a language such as C ++ or Java without taking another introductory
course, or reading another book, on the programming concepts. Conversely,
anyone who learns only programming concepts first (using any language)
would tend to write highly inefficient code using control statements to solve
problems, not realizing that in many cases these are not necessary in MATLAB.
Instead, this book takes a hybrid approach, introducing both the programming
and the efficient uses. The challenge for students is that it is nearly impossible to
predict whether they will in fact need to know programming concepts later on
or whether a software package such as MATLAB will suffice for their careers.
Therefore, the best approach for beginners is to give them both: the program-
ming concepts and the efficient built-in functions. Since MATLAB is very easy to
use, it is a perfect platform for this approach of teaching programming and
problem solving.
As programming concepts are critically important to this book, emphasis is not
placed on the time-saving features that evolve with every new MATLAB release.
xi
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
xii Preface
KEY FEATURES
Side-By-Side Programming Concepts and Built-In Functions
The most important and unique feature of this book is that it teaches program-
ming concepts and the use of the built-in functions in MATLAB, side-by-side. It
starts with basic programming concepts such as variables, assignments, input/
output, selection, and loop statements. Then, throughout the rest of the book,
many times a problem will be introduced and then solved using the “program-
ming concept” and also using the “efficient method.” This will not be done in every
case to the point that it becomes tedious, but just enough to get the ideas across.
Systematic Approach
Another key feature is that the book takes a very systematic, step-by-step
approach, building on concepts throughout the book. It is very tempting in
a MATLAB text to show built-in functions or features early on with a note that
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
Preface xiii
says “we’ll do this later”. This book does not do that; functions are covered
before they are used in examples. Additionally, basic programming concepts
will be explained carefully and systematically. Very basic concepts such as loop-
ing to calculate a sum, counting in a conditional loop, and error-checking are
not found in many texts, but are covered here.
Data Transfer
Many applications in engineering and the sciences involve manipulating large
data sets that are stored in external files. Most MATLAB texts at least mention
the save and load functions, and in some cases, also some of the lower-level file
input/output functions. As file input and output is so fundamental to so many
applications, this book will cover several low-level file input/output functions,
as well as reading from and writing to spreadsheet files. Later chapters will also
deal with audio and image files. These file input/output concepts are introduced
gradually: first load and save in Chapter 3, then lower-level functions in
Chapter 9, and finally sound and images in Chapter 13. A brief introduction to
RESTFUL web functions, which import data from websites is given in Chapter 9.
User-Defined Functions
User-defined functions are a very important programming concept, and yet,
many times the nuances and differences between concepts such as types of
functions and function calls versus function headers can be very confusing
to beginning programmers. Therefore, these concepts are introduced gradually.
First, arguably the easiest types of functions to understand, those that calculate
and return one single value, are demonstrated in Chapter 3. Later, functions
that return no values and functions that return multiple values are introduced
in Chapter 6. Finally, advanced function features are shown in Chapter 10.
Problem-Solving Tools
In addition to the programming concepts, some basic mathematics necessary
for solving many problems will be introduced. These will include statistical
functions, solving sets of linear algebraic equations, and fitting curves to data.
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
xiv Preface
The use of complex numbers and some calculus (integration and differentia-
tion) will also be introduced. The built-in functions in MATLAB to perform
these tasks will be described.
Vectorized Code
Efficient uses of the capabilities of the built-in operators and functions in
MATLAB are demonstrated throughout the book. In order to emphasize the
importance of using MATLAB efficiently, the concepts and built-in functions
necessary for writing vectorized code are treated very early in Chapter 2. Tech-
niques such as preallocating vectors and using logical vectors are then covered
in Chapter 5 as alternatives to selection statements and looping through vectors
and matrices. Methods of determining how efficient the code is are also covered.
Object-Oriented Programming
Creating objects and classes in MATLAB has been an option for some time, but
as of R2014b, all Graphics objects are truly objects. Thus, object-oriented
programming (OOP) is now a very important part of MATLAB programming.
Applications using App Designer reinforce the concepts.
LAYOUT OF TEXT
This text is divided into two parts: the first part covers programming constructs
and demonstrates the programming method versus efficient use of built-in
functions to solve problems. The second part covers tools that are used for basic
problem solving, including plotting, image processing, and techniques to solve
systems of linear algebraic equations, fit curves to data, and perform basic sta-
tistical analyses. The first six chapters cover the very basics in MATLAB and in
programming and are all prerequisites for the rest of the book. After that, many
chapters in the problem-solving section can be introduced when desired, to
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/
This Book is Available on YakiBooki.com
Preface xv
https://www.yakibooki.com/download/matlab-a-practical-introduction-to-programming-and-problem-solving-5th-edition/