Essential MATLAB for engineers and scientists Hahn instant download
Essential MATLAB for engineers and scientists Hahn instant download
Hahn download
https://textbookfull.com/product/essential-matlab-for-engineers-
and-scientists-hahn-3/
https://textbookfull.com/product/essential-matlab-for-engineers-
and-scientists-hahn-2/
https://textbookfull.com/product/essential-matlab-for-engineers-
and-scientists-hahn-3/
https://textbookfull.com/product/essential-matlab-for-engineers-
and-scientists-sixth-edition-edition-hahn/
https://textbookfull.com/product/essential-quotes-for-scientists-
and-engineers-konstantin-k-likharev/
Numerical Methods for Engineers and Scientists Using
MATLAB Second Edition Esfandiari
https://textbookfull.com/product/numerical-methods-for-engineers-
and-scientists-using-matlab-second-edition-esfandiari/
https://textbookfull.com/product/numerical-methods-for-engineers-
and-scientists-using-matlab-ramin-s-esfandiari/
https://textbookfull.com/product/matlab-programming-for-
biomedical-engineers-and-scientists-andrew-p-king-and-paul-
aljabar-auth/
https://textbookfull.com/product/applied-numerical-methods-with-
matlab-for-engineers-and-scientists-fourth-edition-steven-c-
chapra-dr/
https://textbookfull.com/product/the-oceanographers-companion-
essential-nautical-skills-for-seagoing-scientists-and-
engineers-1st-edition-maul/
Essential MATLAB
for Engineers and Scientists
This page intentionally left blank
Essential MATLAB
for Engineers and Scientists
Sixth Edition
Brian H. Hahn
Daniel T. Valentine
Copyright © 2017, 2013, 2010 Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved.
Copyright © 2007, 2006, 2002 Brian D. Hahn and Daniel T. Valentine. Published by Elsevier Ltd.
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.
Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford,
UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: [email protected]. You may
also complete your request online via the Elsevier homepage (http://www.elsevier.com), by selecting
“Support & Contact” then “Copyright and Permission” and then “Obtaining Permissions.”
ISBN: 978-0-08-100877-5
Typeset by VTeX
Contents
PREFACE .............................................................................................................xv
Part 1 Essentials................................................................. 1
CHAPTER 1 Introduction............................................................................... 3
1.1 Using MATLAB..............................................................................5
1.1.1 Arithmetic .........................................................................5
1.1.2 Variables............................................................................7
1.1.3 Mathematical functions ...................................................8
1.1.4 Functions and commands ...............................................8
1.1.5 Vectors...............................................................................9
1.1.6 Linear equations.............................................................11
1.1.7 Tutorials and demos.......................................................12
1.2 The desktop ................................................................................13
1.2.1 Using the Editor and running a script ..........................13
1.2.2 Help, publish and view ...................................................16
1.2.3 Symbolics and the MuPAD notebook APP....................18
1.2.4 Other APPS .....................................................................23
1.2.5 Additional features .........................................................23
1.3 Sample program ........................................................................25
1.3.1 Cut and paste..................................................................25
1.3.2 Saving a program: script files .......................................27
Current directory ................................................................................28
Running a script from the current folder browser ..........................29
1.3.3 A program in action........................................................29
Summary ....................................................................................30
Exercises.....................................................................................31
The main reason for a sixth edition of Essential MATLAB for Engineers and Scien-
tists is to keep up with MATLAB, now in its latest version (9.0 Version R2016a).
Like the previous editions, this one presents MATLAB as a problem-solving
tool for professionals in science and engineering, as well as students in those
fields, who have no prior knowledge of computer programming.
In keeping with the late Brian D. Hahn’s objectives in previous editions, the
sixth edition adopts an informal, tutorial style for its “teach-yourself” ap-
proach, which invites readers to experiment with MATLAB as a way of discov-
ering how it works. It assumes that readers have never used this tool in their
technical problem solving.
MATLAB, which stands for “Matrix Laboratory,” is based on the concept of
the matrix. Because readers will be unfamiliar with matrices, ideas and con-
structs are developed gradually, as the context requires. The primary audience
for Essential MATLAB is scientists and engineers, and for that reason certain ex-
amples require some first-year college math, particularly in Part II. However,
these examples are self-contained and can be skipped without detracting from
the development of readers’ programming skills.
MATLAB can be used in two distinct modes. One, in keeping the modern-age
craving for instant gratification, offers immediate execution of statements (or
groups of statements) in the Command Window. The other, for the more pa-
tient, offers conventional programming by means of script files. Both modes
are put to good use here: The former encouraging cut and paste to take full
advantage of Windows’ interactive environment. The latter stressing program-
ming principles and algorithm development through structure plans.
Although most of MATLAB’s basic (“essential”) features are covered, this book
is neither an exhaustive nor a systematic reference. This would not be in keep-
ing with its informal style. For example, constructs such as for and if are not
always treated, initially, in their general form, as is common in many texts, but
are gradually introduced in discussions where they fit naturally. Even so, they
xv
xvi Preface
are treated thoroughly here, unlike in other texts that deal with them only su-
perficially. For the curious, helpful syntax and function quick references can be
found in the appendices.
The following list contains other highlights of Essential MATLAB for Engineers
and Scientists, Sixth Edition:
Warnings of the many pitfalls that await the unwary beginner
Numerous examples taken from science and engineering (simulation, pop-
ulation modeling, numerical methods) as well as business and everyday
life
An emphasis on programming style to produce clear, readable code
Comprehensive chapter summaries
Chapter exercises (answers and solutions to many of which are given in an
appendix)
A thorough, instructive index
Essential MATLAB is meant to be used in conjunction with the MATLAB soft-
ware. The reader is expected to have the software at hand in order to work
through the exercises and thus discover how MATLAB does what it is com-
manded to do. Learning any tool is possible only through hands-on expe-
rience. This is particularly true with computing tools, which produce correct
answers only when the commands they are given and the accompanying data
input are correct and accurate.
ACKNOWLEDGMENTS
I would like to thank Mary, Clara, Zoe Rae and Zach T. for their support and
encouragement. I dedicate the sixth edition of Essential MATLAB for Engineers
and Scientists to them.
Daniel T. Valentine
1
Part 1 concerns those aspects of MATLAB that you need to know in order to
come to grips with MATLAB’s essentials and those of technical computing. Be-
cause this book is a tutorial, you are encouraged to use MATLAB extensively
while you go through the text.
PART
Essentials
This page intentionally left blank
CHAPTER 1
Introduction
This book assumes that you have never used a computer before to do the sort
of scientific calculations that MATLAB handles, but are able to find your way
3
Essential MATLAB for Engineers and Scientists. DOI:10.1016/B978-0-08-100877-5.00002-5
Copyright © 2017 Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved.
4 CHAPTER 1: Introduction
Summary .............. 30 around a computer keyboard and know your operating system (e.g., Windows,
UNIX or MAC-OS). The only other computer-related skill you will need is
Exercises ............... 31
some very basic text editing.
Supplementary
material ................. 31 One of the many things you will like about MATLAB (and that distinguishes
it from many other computer programming systems, such as C++ and Java) is
that you can use it interactively. This means you type some commands at the
special MATLAB prompt and get results immediately. The problems solved in
this way can be very simple, like finding a square root, or very complicated, like
finding the solution to a system of differential equations. For many technical
problems, you enter only one or two commands—MATLAB does most of the
work for you.
There are three essential requirements for successful MATLAB applications:
You must learn the exact rules for writing MATLAB statements and using
MATLAB utilities.
You must know the mathematics associated with the problem you want to
solve.
You must develop a logical plan of attack—the algorithm—for solving a
particular problem.
This chapter is devoted mainly to the first requirement: learning some basic
MATLAB rules. Computer programming is a precise science (some would also
say an art); you have to enter statements in precisely the right way. There is a
saying among computer programmers: Garbage in, garbage out. It means that if
you give MATLAB a garbage instruction, you will get a garbage result.
With experience, you will be able to design, develop and implement compu-
tational and graphical tools to do relatively complex science and engineering
problems. You will be able to adjust the look of MATLAB, modify the way you
interact with it, and develop a toolbox of your own that helps you solve prob-
lems of interest. In other words, you can, with significant experience, customize
your MATLAB working environment.
As you learn the basics of MATLAB and, for that matter, any other computer
tool, remember that applications do nothing randomly. Therefore, as you use
MATLAB, observe and study all responses from the command-line operations
that you implement, to learn what this tool does and does not do. To begin
an investigation into the capabilities of MATLAB, we will do relatively simple
problems that we know the answers because we are evaluating the tool and its
capabilities. This is always the first step. As you learn about MATLAB, you are
also going to learn about programming, (1) to create your own computational
tools, and (2) to appreciate the difficulties involved in the design of efficient,
robust and accurate computational and graphical tools (i.e., computer pro-
grams).
1.1 Using MATLAB 5
In the rest of this chapter we will look at some simple examples. Don’t be
concerned about understanding exactly what is happening. Understanding will
come with the work you need to do in later chapters. It is very important for
you to practice with MATLAB to learn how it works. Once you have grasped
the basic rules in this chapter, you will be prepared to master many of those
presented in the next chapter and in the Help files provided with MATLAB.
This will help you go on to solve more interesting and substantial problems.
In the last section of this chapter you will take a quick tour of the MATLAB
desktop.
1.1.1 Arithmetic
Since we have experience doing arithmetic, we want to examine if MATLAB
does it correctly. This is a required step to gain confidence in any tool and in
our ability to use it.
Type 2+3 after the >> prompt, followed by Enter (press the Enter key) as
indicated by <Enter>:
>> 2+3 <Enter>
6 CHAPTER 1: Introduction
FIGURE 1.1 MATLAB desktop illustrating the Home task bar (version 2016a).
Commands are only carried out when you enter them. The answer in this case
is, of course, 5. Next try
>> 3-2 <Enter>
>> 2*3 <Enter>
>> 1/2 <Enter>
>> 23 <Enter>
>> 2\11 <Enter>
What about (1)/(2) and (2)^(3)? Can you figure out what the symbols *,
/, and ^ mean? Yes, they are multiplication, division and exponentiation. The
backslash means the denominator is to the left of the symbol and the numer-
ator is to the right; the result for the last command is 5.5. This operation is
equivalent to 11/2.
Now enter the following commands:
>> 2 .* 3 <Enter>
>> 1 ./ 2 <Enter>
>> 2 .ˆ 3 <Enter>
A period in front of the *, /, and ^, respectively, does not change the results
because the multiplication, division, and exponentiation is done with single
numbers. (An explanation for the need for these symbols is provided later
when we deal with arrays of numbers.)
1.1 Using MATLAB 7
1.1.2 Variables
Now we will assign values to variables to do arithmetic operations with the
variables. First enter the command (statement in programming jargon) a = 2.
The MATLAB command line should look like this:
>> a = 2 <Enter>
The a is a variable. This statement assigns the value of 2 to it. (Note that this
value is displayed immediately after the statement is executed.) Now try enter-
ing the statement a = a + 7 followed on a new line by a = a * 10. Do you
agree with the final value of a? Do we agree that it is 90?
Now enter the statement
>> b = 3; <Enter>
The semicolon (;) prevents the value of b from being displayed. However, b
still has the value 3, as you can see by entering without a semicolon:
>> b <Enter>
Assign any values you like to two variables x and y. Now see if you can assign
the sum of x and y to a third variable z in a single statement. One way of doing
this is
>> x = 2; y = 3; <Enter>
>> z = x + y <Enter>
8 CHAPTER 1: Introduction
Notice that, in addition to doing the arithmetic with variables with assigned
values, several commands separated by semicolons (or commas) can be put
on one line.
commands is that functions usually return with a value (e.g., the date), while
commands tend to change the environment in some way (e.g., clearing the
screen or saving some statements to the workspace).
1.1.5 Vectors
Variables such as a and b that were used in Section 1.1.2 above are called scalars;
they are single-valued. MATLAB also handles vectors (generally referred to as
arrays), which are the key to many of its powerful features. The easiest way
of defining a vector where the elements (components) increase by the same
amount is with a statement like
>> x = 0 : 10; <Enter>
That is a colon (:) between the 0 and the 10. There is no need to leave a space
on either side of it, except to make it more readable. Enter x to check that x
is a vector; it is a row vector—consisting of 1 row and 11 columns. Type the
following command to verify that this is the case:
>> size(x) <Enter>
Part of the real power of MATLAB is illustrated by the fact that other vectors
can now be defined (or created) in terms of the just defined vector x. Try
>> y = 2 .* x <Enter>
>> w = y ./ x <Enter>
and
>> y = sin(x) <Enter>
(no semicolons). Note that the first command line creates a vector y by multi-
plying each element of x by the factor 2. The second command line is an array
operation, creating a vector w by taking each element of y and dividing it by
the corresponding element of x. Since each element of y is two times the cor-
responding element of x, the vector w is a row vector of 11 elements all equal
to 2. Finally, z is a vector with sin(x) as its elements.
To draw a reasonably nice graph of sin(x), simply enter the following com-
mands:
>> x = 0 : 0.1 : 10; <Enter>
>> z = sin(x); <Enter>
>> plot(x,z), grid <Enter>
The graph appears in a separate figure window. To draw the graph of the sine
function illustrated in Figure 1.2 replace the last line above with
>> plot(x,y,’-rs’,’LineWidth’,2,’MarkerEdgeColor’,’k’,’MarkerSize’,5),grid
<Enter>
10 CHAPTER 1: Introduction
x + 2y = 4
2x − y = 3
x =
2
1
i.e., x = 2, y = 1.
Built-in solve function. Type the following commands (exactly as they are):
>> [x,y] = solve(’x+2*y=4’,’2*x - y=3’) <Enter >
>> whos <Enter >
>> x = double(x), y=double(y) <Enter >
>> whos <Enter >
12 CHAPTER 1: Introduction
The function double converts x and y from symbolic objects (another data type
in MATLAB) to double arrays (i.e., the numerical-variable data type associated
with an assigned number).
To check your results, after executing either approach, type the following com-
mands (exactly as they are):
>> x + 2*y % should give ans = 4 <Enter >
>> 2*x - y % should give ans = 3 <Enter >
The % symbol is a flag that indicates all information to the right is not part of
the command but a comment. (We will examine the need for comments when
we learn to develop coded programs of command lines later on.)
Author: Various
Language: English
APPLETONS'
POPULAR SCIENCE
MONTHLY
EDITED BY
WILLIAM JAY YOUMANS
VOL. LV
MAY TO OCTOBER, 1899
NEW YORK
D. APPLETON AND COMPANY
1899
Copyright, 1899,
By D. APPLETON AND COMPANY.
WILLIAM PENGELLY.
FEBRUARY, 1899.
ALASKA AND THE KLONDIKE.
A JOURNEY TO THE NEW ELDORADO.
By ANGELO HEILPRIN,
professor of geology at the academy of natural sciences of philadelphia, fellow of the royal
geographical society of london.
The advance in culture typified by our vases was equaled in all the details of life.
The people built strongly walled cities; they constructed roads and bridges; their
architecture, true predecessor of the Roman, was unique and highly evolved. All the
plain and good things of life were known to these people, and their civilization was
rich in its luxury, its culture and art as well. In costumes, jewelry, the paraphernalia
of war, in painting and statuary they were alike distinguished. Their mythology was
very complex, much of the Roman being derived from it. Most of our knowledge of
them is derived from the rich discoveries in their chambered tombs, scattered all
over Italy from Rome to Bologna. There can be no doubt of a very high type of
civilization attained long before the Christian era. Roman history is merged in the
obscurity of time, five or six hundred years later than this. The high antiquity of the
Etruscan is therefore beyond question. But its highly evolved art and culture show
that we have no longer to do with European origins; to discuss it further would lead
us to trench upon the field of classical rather than prehistoric archæology.
V. The northwestern corner of Europe, including Scandinavia, Denmark, and the
Baltic plain of Germany, throughout the prehistoric period has been characterized
by backwardness of culture as compared with the rest of Europe. It was populated
from the south, deriving a large part of such primitive civilization as it possessed
from the south and the southeast as well.
That this region was necessarily uninhabited during the Glacial epoch, long after the
advent of man in southern Europe, is indubitable. It is proved by the extent of the
glaciated area, which extends on the mainland as far south as Hamburg, Berlin, and
Posen, and over the entire British Isles at the same time.[13] It was by the melting
of this vast sheet of ice that those high level river terraces in France and Belgium
were formed, in which the most ancient and primitive implements of human
manufacture occur. In the area beneath this ice sheet no trace of human occupation
until long after this time occurs. This fact of itself, is not absolutely conclusive, for
glaciation would have obliterated all traces of anterior habitation or activity. As to
the possibility of a tertiary population before the Glacial epoch, it presents too
remote a contingency for us to consider, although we do not deny its possibility. It
too far antedates prehistory, so to speak.
At the notable International Congress of Anthropology and Prehistoric Archæology
at Stockholm in 1874 a landmark in these sciences was established by substantial
agreement among the leading authorities from all over Europe upon the proposition
now before us.[14] First of all, every one subscribed to the view that the palæolithic
or oldest stone age was entirely unrepresented in Sweden. The earliest and
simplest stone implements discovered in the southern part of that country betray a
degree of skill and culture far above that so long prevalent in France and Germany.
Stone is not only rubbed and polished into shape, but the complicated art of boring
holes in it has been learned. Norway also seems to be lacking in similar evidence of
a human population in the very lowest stage of civilization. Stone implements
anterior to the discovery of the art of rubbing or polishing are almost unknown.
Only about Christiania have any finds at all been made. In Denmark some few very
rude implements have been found. They are so scarce as to suggest that they are
mere rejects or half-finished ones of a later type. The kitchen middens, or shell
heaps, of Jutland, for which the region is most notable, as described by Steenstrup,
abound in stone implements. They all represent man in the neolithic age. Polished
stones are as abundant as the rudely hammered ones are rare. From the absence
of all the very early stone implements, and from the sudden appearance of others
of a far more finished type, the possibility of a gradual evolution of culture about
Scandinavia in situ is denied on all hands. The art of working stone has surely been
introduced from some more favored region. The only place to look for the source of
this culture is to the south.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com