(eBook PDF) Essentials of MATLAB Programming 3rd Edition download
(eBook PDF) Essentials of MATLAB Programming 3rd Edition download
Edition download
https://ebookluna.com/product/ebook-pdf-essentials-of-matlab-
programming-3rd-edition/
https://ebookluna.com/product/ebook-pdf-matlab-programming-for-
engineers-6th-edition/
MATLAB Programming for Engineers 6th Edition Stephen J. Chapman - eBook PDF
https://ebookluna.com/download/matlab-programming-for-engineers-ebook-pdf/
https://ebookluna.com/product/ebook-pdf-matlab-a-practical-introduction-to-
programming-and-problem-solving-4th-edition/
https://ebookluna.com/product/numerical-methods-in-engineering-with-
matlab-3rd-edition/
(eBook PDF) Numerical Methods in Engineering with MATLAB 3rd Edition
https://ebookluna.com/product/ebook-pdf-numerical-methods-in-engineering-
with-matlab-3rd-edition/
https://ebookluna.com/product/ebook-pdf-python-programming-in-context-3rd-
edition/
https://ebookluna.com/product/python-programming-in-context-3rd-edition-
ebook-pdf/
https://ebookluna.com/product/ebook-pdf-essentials-of-marketing-
research-3rd-edition/
https://ebookluna.com/product/foundations-of-computational-finance-with-
matlab-ebook-pdf/
ESSENTIALS OF ESSENTIALS OF
CHAPMAN
MATLAB
PROGRAMMING
MATLAB
PROGRAMMING
ESSENTIALS OF
STEPHEN J. CHAPMAN STEPHEN J. CHAPMAN
THIRD EDITION
MATLAB
PROGRAMMING
To register or access your online learning solution or purchase materials
for your course, visit www.cengagebrain.com.
3E
THIRD EDITION
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Preface | vii
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
viii | Preface
4. Device-independent plotting.
Unlike other computer languages, MATLAB has many integral plot-
ting and imaging commands. The plots and images can be displayed
on any graphical output device supported by the computer on which
MATLAB is running. This capability makes MATLAB an outstanding
tool for visualizing technical data.
5. Graphical user interface.
MATLAB includes tools that allow a programmer to interactively con-
struct a graphical user interface (GUI) for his or her program. With
this capability, the programmer can design sophisticated data analysis
programs that can be operated by relatively inexperienced users.
Pedagogical Features
This book is specifically designed to be used in a first-year “Introduction to
Programming/Problem Solving” course. It should be possible to cover this material
comfortably in a 9-week, 3-hour-per-week course. If there is insufficient time to
cover all of the material in a particular engineering program, Chapters 8 and 9
may be deleted, and the remaining material will still teach the fundamentals of
programming and using MATLAB to solve problems. This feature should ap-
peal to harassed engineering educators trying to cram ever more material into a
finite curriculum.
The book includes several features designed to aid student comprehension.
A total of 14 quizzes appear scattered throughout the chapters, with answers
to all questions included in Appendix C. These quizzes can serve as a useful
self-test of comprehension. In addition, there are approximately 150 end-of-
chapter exercises. Answers to all exercises are included in the Instructor’s Man-
ual. Good programming practices are highlighted in all chapters with special
Good Programming Practice boxes, and common errors are highlighted in Pro-
gramming Pitfalls boxes. End-of-chapter materials include Summaries of Good
Programming Practice and Summaries of MATLAB Commands and Functions.
Instructor Resources
A detailed Instructor’s Solutions Manual containing solutions to all end-of-
chapter exercises is available via the secure, password-protected Instructor
Resource Center at https://sso.cengage.com. The Instructor Resource Center
also contains helpful Lecture Note PowerPoint slides, the MATLAB source code
for all examples in the book, and the source code for all of the solutions in the
Instructor’s Solutions Manual.
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Preface | ix
Acknowledgments
I would like to thank these reviewers who offered their helpful suggestion for
this edition:
David Eromom Georgia Southern University
Arlene Guest Naval Postgraduate School
Mary M. Hofle Idaho State University
Mark Hutchenreuther California Polytechnic State
University
Mani Mini Iowa State University
In addition I would like to acknowledge and thank my Global Engineering team
at Cengage Learning for their dedication to this edition:
Timothy Anderson, Product Director; Mona Zeftel, Senior Content Developer;
D. Jean Buttrom, Content Project Manager; Kristin Stine, Marketing Manager;
Elizabeth Murphy and Brittany Burden, Learning Solutions Specialists; Ashley
Kaupert, Associate Media Content Developer; Teresa Versaggi and Alexander
Sham, Product Assistants; and Rose Kernan of RPK Editorial Services, Inc.
They have skillfully guided every aspect of this text’s development and produc-
tion to successful completion.
In addition, I would like to thank my wife Rosa for her help and encourage-
ment over the more than 40 years we have spent together.
Stephen J. Chapman
Melbourne, Australia
November 8, 2015
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
MindTap Online Course
Index 479
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
Chapter 1
Introduction to MATLAB
1
Copyright 2018 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. WCN 02-200-203
2 | Chapter 1 Introduction to MATLAB
the scientist or engineer how to use MATLAB’s own tools to locate the right func-
tion for a specific purpose from the enormous list of choices available. In addition,
it teaches how to use MATLAB to solve many practical engineering problems, such
as vector and matrix algebra, curve fitting, differential equations, and data plotting.
The MATLAB program is a combination of a procedural programming language,
an integrated development environment (IDE) including an editor and debugger, and
an extremely rich set of functions to perform many types of technical calculations.
The MATLAB language is a procedural programming language, meaning that the
engineer writes procedures, which are effectively mathematical recipes for solving a
problem. This makes MATLAB very similar to other procedural languages such as C,
Basic, Fortran, and Pascal. However, the extremely rich list of predefined functions
and plotting tools makes it superior to these other languages for many engineering
analysis applications.
"Sprinkled isles,
Lily on lily that o'erlace the sea,
And laugh their pride when the light waves
whisper 'Greece.'"
An old writer says that there are two-and-thirty thousand of them,
great and small, clustered chiefly where Huron leans her head to
meet those of Michigan and Superior, "as if they were discussing
some great matter." Perhaps they are talking over the old days and
the things and people they knew long ago. Perhaps they speak of
the morning when, according to an old saga, the worshippers of the
Rising Sun in February saw the Island like a great turtle—
Nocchenemockenung—rise slowly out of the water, to become the
home of the Giant Fairies of the Michsawgyegan, or Lake Country,
and to be a place of refuge for the vanished peoples, whose names
are as the sound of many waters for beauty and for harmony.
Perhaps they tell of the wild, free life of those roving, painted bands
of fishers, trappers, and hunters which make pictures of so much
action and color against the ever-shifting background of these seas
and shores. Perhaps they tell of the coming of the Black Robes in
the days when the lilies of France had no fear of the lion of England,
and the eagle of the American Republic was as yet unthought of.
There are things enough of which the Lakes may speak as their
waves lapse on the beach of
In the days when New France "had two fountain heads, one in the
cane brakes of Louisiana, and the other in the snows of Canada," a
charter was given by Louis XIII. to the Hundred Association
Company, which was thereby invested with rights almost
monarchical, together with injunctions to do all that was possible for
Holy Church which was consistent with the keeping of a watchful eye
upon such earthly advantages as might accrue from a monopoly of
the fur trade and the acquisition of new territory. It was in 1634,
under the governorship of Champlain, that Jean Nicolet, a fearless
explorer, well versed in woodcraft and in the speech of many
aboriginal tribes, was the first paleface to see the white cliffs of
Mackinac, as he was also the first to carry back to civilization tidings
of a great new sea, the Lac des Ilinese, or Michigan, which he had
discovered. That he perished by the capsizing of his canoe in the St.
Lawrence River was a great loss to the infant colonies to whom his
sixteen years' experience in frontier life would have been very
valuable. The path he opened, was, however, soon followed by
others. The explorers and traders, Des Grosselliers, Radisson, Perrot,
and their fellows did for the world what the Jesuits, the Recollets,
and the Sulpicians did for the Church. It is in the Relations sent
home by the priests that we learn what were the trials overcome by
those dauntless sons of "the sturdy North." Perhaps from no country
but France, and in no other years than the glittering, romantic,
covetous, daring, devoted years of the seventeenth century, could
have come adventurers so tireless and churchmen so selfless as
these. To read their simple, patient chronicles is to have new belief
in man, new faith in the Church Universal, "which is the blessed
company of all faithful people," and to clasp hands across years and
above creeds with those courageous pioneers and with those
humble saints.
The story of Mackinac is for many years the story of the French in
Canada. "Not a cape was turned," says Parkman, "not a river was
entered, but a Jesuit led the way." Every year the establishment of
new posts pushed the realms of the Unknown Territory nearer and
nearer to the sunset. Poor little posts they were, slenderly
garrisoned, and feebly armed, but beside each one rose a chapel
and a cross where the "bloody salvages" might learn, if they would,
the religion of the fathers. The missionaries made, perhaps, but few
converts to their faith, but they made many friends for their country
by their kindly offices to the sick, the aged, the dying, and the
infant, by the gentleness and urbanity of their high breeding, and by
the perpetual sacrifice of their lives of love and loyalty. Of their
hardships we can only read between the lines of their brave,
uncomplaining Relations, but what litanies of pain, sorrow, and
disappointment, what Te Deums of hope and rejoicing lie in these
marks, oft recurring on their queer old maps:
marque des villages sauvages
marque des etablissements françois.
By 1668 many missions were strung along the waterways. The
Island was the centre of a thriving trade, had thirty native villages,
and a palisaded enclosure for defence, and a year later its shores
were hallowed by the feet of "The Guardian Angel of the Ottawa
Mission," Father Jacques Marquette.
SUGAR
LOAF
ROCK,
MACKI
NAC
ISLAND
.
When the French and English war was ended on the Plains of
Abraham, George III. became indeed sovereign of the soil of
Canada, but Louis XV. was lord of the hearts of too many French,
half-breeds, and Indians to make the transfer of allegiance easy.
Loves and hates and racial sympathies are not matters for cold
diplomacy, and the people of the Northwest waited longingly for a
leader who should give them again the light-hearted, friendly rule of
the French, under which they had been far happier than they found
themselves as subjects of the stern, alien English. In the person of
an Ottawa chieftain, the most remarkable personage produced by
the Indian race, the leader was found. In the brain of Pontiac, grim,
far-seeing, fearless, heroic, there arose as a prophetic vision the
assurance that English encroachments upon the rights of his people
would never cease so long as they held a rod of ground coveted by
an English eye. To avert the evils he foresaw, he planned the capture
of all forts west of Niagara, the extermination of all English settlers,
and the restoration to the Great Father at Versailles of the lands he
had just lost. With incredible swiftness he formed the vast
conspiracy whose story has been told, once for all, in the living
pages of Parkman's narrative.
"OLD
STONE
QUART
ERS,"
FORT
MACKI
NAC,
1780.
This event led to the abandonment of the southern fort and the
establishment of one on the Island.[6]
When the second war with England began, it was natural that one
of the first points to be attacked should be the fort so commandingly
situated. Far from all base of supplies and all possibility of rapid
communication, the oft-repeated appeals of General Hull for an
effective garrison at this and other important points were totally
disregarded in Washington. Only fifty-seven soldiers were in
residence in Mackinac when the British forces, 1021 strong, landed
before dawn on the 17th of July, 1812, on a point nearly opposite St.
Ignace. By eleven o'clock Captain Roberts sent a flag of truce, and a
demand of surrender to Lieutenant Porter Hanks, who had had "no
intimation" that a war between the powers had been declared until
that moment. After considering the futility of resistance, and a
consultation with the American traders in the village, with the valor
which was ever bettered by discretion, he capitulated.
In August, 1814, an attempt was made to retake the Island. A
battle was fought near the scene of the British landing two years
before, in which battle Major Holmes and twelve privates were killed,
and many men were wounded or missing. The routed Americans,
under Colonel Croghan, withdrew to their ships. The Island finally
passed into the keeping of the United States in 1815.
Then followed the great days of the fur companies, when the place
was astir with a life so gay and vivid that only to hear of it stirs the
blood of the untamed savage which centuries of the repressions of
civilization have not routed from our hearts. Hundreds of hardy, ill-
paid engagés, hundreds of happy-go-lucky, hard-working voyageurs
and coureurs des bois and hundreds of Indians crowded into the
hundreds of tents set up along the beach; into the log-houses of the
primitive village, and into the huge barracks of the company, which
counted and weighed the rich peltries they had gathered, paying
them in return the miserable wages which in dancing, gambling,
drinking, fighting, feasting and sleeping, were spent long before the
bateaux freighted with the poor necessities for the fast-coming
winter were again rowed out toward the wilderness, the brave
chansons of the oarsmen growing fainter and fainter as the boats
passed steadily out of sight.
REV.
ELEAZA
R
WILLIA
MS.
REPRO
DUCED
FROM
LATIME
R'S
"SCRAP
BOOK
OF THE
REVOL
UTION,
" BY
PERMI
SSION
OF A.C.
McCLU
RG &
CO.
An incident but little known connects the Island with one of the
great mysteries of history,—the fate of the little son of Louis XVI.
and Marie Antoinette. That the Dauphin did not die in the Temple,
but had been secretly conveyed to America and had been placed
among the Indians, was believed by persons whose opinions were
entitled to respect; but that he might be found in the person of the
Rev. Eleazar Williams, a half-breed missionary of the Protestant
Episcopal Church among the tribes about Green Bay, was a
supposition stranger than any fiction. The story is too long to tell
here,[7] but as it touches Mackinac at a single point, it must have a
line in this chapter.
On the wharf of the moon-shaped bay, one bright day in October,
1841, a crowd was gathered to see the Prince de Joinville, son of
Louis Philippe, then reigning in France, who was on his way to Green
Bay, and who had stopped off at Mackinac to visit some of the
natural curiosities of the place. A salute had been fired in honor of
the royal sailor with true republican fervor, and while the steamer
which had brought him waited his pleasure, the village was en fête.
Waiting on the dock, and also about to embark for Green Bay, was
the Rev. Eleazar Williams, who, before the boat left the bay, was, at
the request of the Prince, presented to his Highness. The
acquaintance thus begun led to disclosures which, if true, make the
identity of the Dauphin and the missionary all but certain.
Wrapped in a legend, the Island of Mackinac comes into sight. With
a thousand legends, its old fields, its cliffs, its caves, its gorges, its
wooded glens, its shores, and its far, dim distances are haunted.
With a thousand mysteries and bewilderments and witcheries it
holds captive all who come within reach of its magic. With a mystery,
which too may be but a legend, our story closes, as the light that
smites the waters of the Straits into a myriad of glittering flakes
paints on the sunset sky the old, old golden track which the Indians
loved to call "the Path that leads Homeward."
INDIANAPOLIS
By PERRY S. HEATH
At the time this city was located and titled there was so much of
Indian lore in the minds of the legislators, and in fact so much of the
red man in the wilderness around, a constant source of
apprehension, that great difficulty was found in securing a name for
the new metropolis. Tecumseh, Suwarrow, Whetzel, Wayne,
Delaware, and other names familiar to the paleface hunted by or
hunting the red man, were suggested. Finally Mr. Samuel Merrill, a
name significant in the modern history of Indiana and Indianapolis,
and prominent in the upbuilding and development of the best
institutions of the State and city, proposed indianapolis as the name
for the city which is now the pride of all Hoosier hearts.
The original city was platted with streets just one mile in length
from end to end. The avenues, or "diagonals," as they were termed
on the original plat, radiated from the Circle (the hub) in the centre
and constituted that beautiful design which makes the capital of
France and the capital of the United States so attractive in
appearance, and yet in some respects "a labyrinth or mesh to the
unfamiliar." Near the radiating point or
Circle was early established a market, which
is to-day one of the great conveniences to
the residents of the city and to those who
market their products and an attraction at
most seasons of the year to visitors.
It was not until the removal in November,
1824, of the archives of Indiana from
Corydon to Indianapolis, that the latter
became the actual capital. In 1827 the
Legislature appropriated four thousand
dollars for a Governor's residence to be
Benjamin Harrison located in the Circle. Its construction was
commenced, but never completed. The
unfurnished portion was occupied at one time as a schoolhouse,
until finally the officers of the Supreme Court made it their
headquarters. After some years the crude building was demolished
and the ground was converted into a park, the present location of
the Soldiers' Monument.
STATE
HOUSE
,
INDIAN
APOLIS
. EAST
FRONT.
It was not until a third of the nineteenth century had passed, not
until near 1840, that Indianapolis became more pretentious than any
other country town. The public squares were feeding-grounds for
the ox and horse teams of countrymen who came to market. There
were practically no industries, and the buildings were primitive and
simple. As late as 1875 the wags of the stage and the humorists of
the press amused themselves with jeers at the Hoosier capital. The
Hoosier was a joke in the East. He was represented as the typical
raw character, greatly in need of common advantages and ordinary
enlightenment. And the impression persisted until some time after
three quarters of the nineteenth century had passed that
Indianapolis was simply a congregating-point for him and his kind.
About 1880 the city began to take on the appearance of a modern
ambitious metropolis. As wealth increased the people resorted in
ever increasing numbers to the capital, to enjoy the schools for their
children and the best civilization for themselves. Gradually there
have gathered there not only the prosperous citizens of the State,
but many who have at home or abroad achieved renown in letters,
diplomacy, official life, the army and navy. Here have lived two Vice-
Presidents of our country. One of our Presidents, the late General
Benjamin Harrison, lived and died here. Dialect poets, local
historians, and novelists have spent their days here and been the
pride of their fellow-citizens.
In 1831 the Legislature made an appropriation of fifty thousand
dollars for the construction of a State House. The investment, when
completed, however, aggregated about sixty thousand dollars. And
the State viewed the result with satisfaction and believed she had
one of the most attractive and majestic State Houses in the entire
country, as indeed she had after the substitution in 1887, at an
expense of $1,936,000, of the present magnificent structure.
Indianapolis has more than one hundred church buildings. The City
Hall, with a seating capacity of over five thousand, the gift of Mr.
Daniel Tomlinson, was constructed at an expense of $150,000, and
is principally used for conventions and musical festivals.
In 1836 the State began an elaborate system of internal
improvements. Railroads, canals, and turnpikes were subsidized and
encouraged in every manner possible. The first railroad to reach
Indianapolis came up in 1847 from Madison, on the Ohio River,
creating the usual sensation of the new railroad in those days. As
long ago as 1860 Indianapolis became the railroad centre of the
Central West. The diversified and almost limitless products of the
State, of the farm and the mine, and the fact that Indianapolis is in
the direct pathway between the East and the West, afforded great
attraction to railroad builders. The Union Railroad Station, until
recently the largest and best in the United States, is still one of the
most commodious, comfortable, and beautiful in the country.
During the Civil War Indianapolis was a storm-centre. The State
was not surpassed by any other in the percentage of soldiers sent
out to defend the Union. Here they rendezvoused, and Camp Morton
and other points about the city for many years after the war bore
signs of the long presence of the "Boys in Blue." Indiana possessed
a great war Governor in Oliver P. Morton, the steadfast friend of
Lincoln and a loyal anti-slavist. For five years in Indianapolis the
shrill sound of the fife and the roll of the drum scarcely ever ceased,
day or night. Those living to-day who recall the activities of the days
of the Civil War view the Soldiers' Monument, in the heart of the city,
and the many evidences of reverence for the memory of our Union
soldiers in the beautiful cemeteries without surprise. These to them
are but simple sequences, natural results.
SOLDIE
RS'
MONU
MENT,
INDIAN
APOLIS
.
The straggling village of the first days of the war soon became a
bustling little city. For the first time business blocks began to appear
along the leading streets and avenues. The architecture in the
residences evinced a tendency toward the modern as time
progressed. The corduroy or cobble streets were improved. The
heavy artillery and ponderous wagons carrying munitions of war
required something more substantial in heavy weather, and gravel
was thrown upon the muddy thoroughfares. Level as a plain, but
beautifully drained by the slight inclines to the White River, it was
possible to transform those streams of mud in winter-time and
heaps of brown dust in the dry summer into the magnificently paved
or perfectly asphalted streets of the present day. The city now has
150 miles of improved streets—forty miles of asphalt, costing
$2,514,576; twenty-three miles of brick, $902,276; twelve miles of
wooden block, $710,646, and seventy-five miles of gravel and
boulder, $777,306. There are 107 miles of cement sidewalks, which
required an expenditure of $552,489, and ninety-one miles of
sewers, at an outlay of $1,575,878.
MARIO
N
COUNT
Y
COURT
HOUSE
.
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.
ebookluna.com