Solution Manual for MATLAB: A Practical Introduction to Programming and Problem Solving 5th Edition - Read Now Or Download For A Complete Experience
Solution Manual for MATLAB: A Practical Introduction to Programming and Problem Solving 5th Edition - Read Now Or Download For A Complete Experience
http://testbankbell.com/product/solution-manual-for-organizational-
behavior-a-practical-problem-solving-approach-3rd-edition-angelo-
kinicki/
http://testbankbell.com/product/solution-manual-for-problem-solving-
and-programming-concepts-9-e-9th-edition-maureen-sprankle-jim-hubbard/
http://testbankbell.com/product/test-bank-for-organizational-behavior-
a-practical-problem-solving-approach-3rd-edition-angelo-kinicki/
http://testbankbell.com/product/test-bank-for-essentials-for-nursing-
practice-9th-edition-by-potter/
Test Bank for Fundamentals of Abnormal Psychology, 9th
Edition, Ronald J. Comer, Jonathan S. Comer
http://testbankbell.com/product/test-bank-for-fundamentals-of-
abnormal-psychology-9th-edition-ronald-j-comer-jonathan-s-comer/
http://testbankbell.com/product/test-bank-for-cfin-3-3rd-edition-
besley/
http://testbankbell.com/product/test-bank-virtual-clinical-excursions-
medical-surgical-nursing-lewis-9th-edition/
http://testbankbell.com/product/test-bank-for-macroeconomics-6th-
edition-r-glenn-hubbard-anthony-patrick-obrien/
http://testbankbell.com/product/test-bank-for-fundamentals-of-
abnormal-psychology-eighth-edition/
Current Diagnosis and Treatment Obstetrics and Gynecology
by Alan Test Bank
http://testbankbell.com/product/current-diagnosis-and-treatment-
obstetrics-and-gynecology-by-alan-test-bank/
Solution Manual for MATLAB: A
Practical Introduction to Programming
and Problem Solving 5th Edition
Full download chapter at: https://testbankbell.com/product/solution-manual-for-
matlab-a-practical-introduction-to-programming-and-problem-solving-5th-
edition/
Exercises
9 7 5 3
>> 3:8
ans =
3 4 5 6 7 8
>> 1.3: 0.4: 2.5
ans =
1.3000 1.7000 2.1000 2.5000
>> 9: -2: 3
ans =
9 7 5 3
6) Using a built-in function, create a vector vec which consists of 30 equally spaced
points in the range from –2*pi to +pi.
7) Write an expression using linspace that will result in the same as 1:0.5:3
>> 1: 0.5: 3
ans =
1.0000 1.5000 2.0000 2.5000 3.0000
>> linspace(1,3,5)
ans =
1.0000 1.5000 2.0000 2.5000 3.0000
8) Using the colon operator and also the linspace function, create the following row
vectors:
-4 -3 -2 -1 0
9 7 5
4 6 8
>> -4:0
ans =
-4 -3 -2 -1 0
>> linspace(-4, 0, 5)
ans =
-4 -3 -2 -1 0
>> 9:-2:5
ans =
9 7 5
>> linspace(9, 5, 3)
ans =
9 7 5
>> 4:2:8
ans =
4 6 8
>> linspace(4,8,3)
ans =
4 6 8
9) How many elements would be in the vectors created by the following expressions?
linspace(3,2000)
logspace(3,2000)
10) Create a variable myend which stores a random integer in the inclusive range from
5 to 9. Using the colon operator, create a vector that iterates from 1 to myend in steps
of 3.
11) Create two row vector variables. Concatenate them together to create a new row
vector variable.
12) Using the colon operator and the transpose operator, create a column vector
myvec that has the values -1 to 1 in steps of 0.5.
colvec = 1:3’
14) Write an expression that refers to only the elements that have odd-numbered
subscripts in a vector, regardless of the length of the vector. Test your expression on
vectors that have both an odd and even number of elements.
15) Generate a 2 x 4 matrix variable mat. Replace the first row with 1:4. Replace the
third column (you decide with which values).
16) Generate a 2 x 4 matrix variable mat. Verify that the number of elements is equal to
the product of the number of rows and columns.
17) Which would you normally use for a matrix: length or size? Why?
18) When would you use length vs. size for a vector?
>> rand(2,3)
ans =
0.5208 0.5251 0.1665
0.1182 0.1673 0.2944
>> rand(2,3)*5
ans =
1.9468 2.3153 4.6954
0.8526 2.9769 3.2779
20) Create a variable rows that is a random integer in the inclusive range from 1 to 5.
Create a variable cols that is a random integer in the inclusive range from 1 to 5.
Create a matrix of all zeros with the dimensions given by the values of rows and cols.
21) Create a vector variable vec. Find as many expressions as you can that would
refer to the last element in the vector, without assuming that you know how many
elements it has (i.e., make your expressions general).
22) Create a matrix variable mat. Find as many expressions as you can that would
refer to the last element in the matrix, without assuming that you know how many
elements or rows or columns it has (i.e., make your expressions general).
The function flip is equivalent to the function fliplr for a row vector.
The function flip is equivalent to the function flipud for a column vector.
The function flip is equivalent to the function flipud for a matrix.
26) Use reshape to reshape the row vector 1:4 into a 2x2 matrix; store this in a variable
named mat. Next, make 2x3 copies of mat using both repelem and repmat.
27) Create a 3 x 5 matrix of random real numbers. Delete the third row.
>> mat(3,:) = []
mat =
0.5226 0.9797 0.8757 0.0118 0.2987
0.8801 0.2714 0.7373 0.8939 0.6614
Because the left and right sides are not the same dimensions.
30) Create a vector x which consists of 20 equally spaced points in the range from – to
+. Create a y vector which is sin(x).
>> x = linspace(-pi,pi,20);
>> y = sin(x);
31) Create a 3 x 5 matrix of random integers, each in the inclusive range from -5 to 5.
Get the sign of every element.
32) Find the sum 2+4+6+8+10 using sum and the colon operator.
>> sum(2:2:10)
ans =
30
33) Find the sum of the first n terms of the harmonic series where n is an integer
variable greater than one.
1 1 1 1
1 + + + + +…
2 3 4 5
>> n = 4;
>> sum(1./(1:n))
ans =
2.0833
34) Find the following sum by first creating vectors for the numerators and
denominators:
3 5 7 9
+ + +
1 2 3 4
35) Create a matrix and find the product of each row and column using prod.
>> prod(mat)
ans =
55 240 80
>> prod(mat,2)
ans =
4224
250
36) Create a 1 x 6 vector of random integers, each in the inclusive range from 1 to 20.
Use built-in functions to find the minimum and maximum values in the vector. Also
create a vector of cumulative sums using cumsum.
37) Write a relational expression for a vector variable that will verify that the last value in
a vector created by cumsum is the same as the result returned by sum.
38) Create a vector of five random integers, each in the inclusive range from -10 to 10.
Perform each of the following:
40) Find two ways to create a 3 x 5 matrix of all 100s (Hint: use ones and zeros).
ones(3,5)*100
zeros(3,5)+100
A B
é 1 2 3 ùé
ê 2 4 1 ù
ú ê ú
ë 4 -1 6 û ë 1 3 0 û
é2 8 3 ù
ê ú
ë 4 -3 0 û
42) A vector v stores for several employees of the Green Fuel Cells Corporation their
hours worked one week followed for each by the hourly pay rate. For example, if the
variable stores
>> v
v =
33.0000 10.5000 40.0000 18.0000 20.0000 7.5000
that means the first employee worked 33 hours at $10.50 per hour, the second worked
40 hours at $18 an hour, and so on. Write code that will separate this into two vectors,
one that stores the hours worked and another that stores the hourly rates. Then, use
the array multiplication operator to create a vector, storing in the new vector the total
pay for every employee.
>> mat
mat =
1 -5 0 -2 10
2 1 1 6 -3
-6 10 -3 5 2
>> sum(sum(mat < 0))
ans =
5
44) A company is calibrating some measuring instrumentation and has measured the
radius and height of one cylinder 8 separate times; they are in vector variables r and h.
Find the volume from each trial, which is given by Πr2h. Also use logical indexing first to
make sure that all measurements were valid (> 0).
3 12
9 6
• Are there any other matrix multiplications that can be performed? If so, list them.
C*B
46) Create a row vector variable r that has 4 elements, and a column vector variable c
that has 4 elements. Perform r*c and c*r.
47) The matrix variable rainmat stores the total rainfall in inches for some districts for
the years 2014-2017. Each row has the rainfall amounts for a given district. For
example, if rainmat has the value:
>> rainmat
ans =
25 33 29 42
53 44 40 56
etc.
district 1 had 25 inches in 2014, 33 in 2015, etc. Write expression(s) that will find the
number of the district that had the highest total rainfall for the entire four year period.
48) Generate a vector of 20 random integers, each in the range from 50 to 100. Create
a variable evens that stores all of the even numbers from the vector, and a variable
odds that stores the odd numbers.
49) Assume that the function diff does not exist. Write your own expression(s) to
accomplish the same thing for a vector.
50) Create a vector variable vec; it can have any length. Then, write assignment
statements that would store the first half of the vector in one variable and the second
half in another. Make sure that your assignment statements are general, and work
whether vec has an even or odd number of elements (Hint: use a rounding function
such as fix).
Those who have perused that polyglot of wisdom and wit, learning
and fun, wild eccentricity and plain sense, 'yclept "The Prout Papers,"
which originally appeared in Fraser's Magazine, during the editorship
of Dr. Maginn, may feel some curiosity respecting the individual
whose name has thus been preserved (not unlike the fly in amber)
through all literary time. They would naturally think, after admiring
the rare facility of versification, the playfulness, the fancy, the wit,
the impetuous frolic, the deep erudition which distinguishes the said
"Papers," that Father Prout must have been a wonderful man, gifted
in an extraordinary manner.
What is there in the language more spirited than the Prout
translations from Béranger? As was said of Goethe's Faust,
translated by Anster, the fact was transfused into our vernacular.
What wondrous flexibility is given to the old Latin tongue, by the
versions of Moore into that language! What charming mastery of
learning, as exhibited in the translations of "The Groves of Blarney"
into a variety of tongues! What grave humour in treating that
original song as if it were only a translation! Two wits—who not only
belonged to Cork, but had seen a great many drawings of it in their
time—were the perpetrators of this literary mystification. Frank
Mahony and Frank Murphy—a priest and a lawyer. On their own
hook, to use a common phrase, they have done nothing worth
particular mention; but some plants, we know, produce flowers,
while others yield fruit.
For a long time, in England, the full credit of the Fraserian articles
was given to Father Prout. Then set in a spring-tide of disbelief, and
the very existence of such a man was doubted. Erroneous doubt! for
I have seen him—spoken to him—dined with him. The Father Prout,
however, of real life was very different from him of the Prout Papers.
He was parish-priest of Watergrass-hill, midway between the city of
Cork and the town of Fermoy—a locality known as the highest arable
land in Ireland. Prout was one of the old priests who, when it was
penal for a Catholic clergyman to exist in Ireland, picked up the
elements of his education how he could, completed it at a foreign
university, and came back to Ireland, a priest, to administer the
consolations of religion to the peasantry of his native land.
Sometimes, the Catholic priest evidenced to the last, in conduct and
manners, that his youth had been passed in countries in which social
civilization had extended further than in Ireland. Sometimes, the
learning and the polish which had been acquired abroad were
forgotten at home—as the sword loses its brightness from disuse—
and, living much among the peasantry, the priest lost a part of the
finer courtesy of the gentleman, and assumed the roughness of the
bulk of his parishioners. Wherever there was a resident Protestant
landowner, the Priest of the olden time instinctively formed friendly
relations with him—for, at that time, the priestly order was not
invariably supplied from the peasantry, and tolerance was more
declared and practiced by members of all persuasions, in Ireland, at
that time than it is now. Prout was literally a "round, fat, oily man of
God." He had a hand small as a woman's, and was very proud of it.
He had an unconquerable spirit of good-humour, and it was utterly
impossible for any one to be in his company for ten minutes without
feeling and basking in the sunshine of his buoyant and genial good-
nature. Of learning he had very little. I do not know what his share
might have been half a century before, when he was fresh from
Douay or the Sorbonne, but few traces were left in his latter years.
In the society of his equals or his superiors, Prout could keep up the
shuttlecock of conversation as well as any one, and in the fashion of
the place and class, but he was equally at home amid the festivities
of a country wedding, or the genialities of the hospitable
entertainment which followed the holding of a country Station at a
rich farmer's domicile.
What the world has received as "The Reliques of Father Prout," owes
nothing to the little padrone. He had a strong sense of the
humourous, and, when the fancy seized him, was not very particular
how or where he indulged it.
Prout, residing only nine miles from Cork, frequently visited that city,
where he had a great many acquaintances, at all times glad to see
him. In one Protestant family with which he was intimate, there
were several very handsome daughters, full of life and high spirits,
who especially delighted in drawing out the rotund priest. He had
repeatedly urged them to "drop in" upon him, some day; and when
the spirit of fun was strong, early on a Sunday morning in June, they
ordered out the carriage, and directed their Jehu to drive them to
Watergrass-hill.
Now, though that terminus was only nine (Irish11) miles distant, the
greater part of the way—certainly all from Glanmire—was terribly
up-hill. The result was that, instead of reaching Father Prout's about
ten o'clock, as they had anticipated, they did not draw up at his door
until an hour and a half later, and were there informed that "his
Reverence had be off to last mass." They determined to follow him,
partly from curiosity to see in what manner divine worship was
performed in a Catholic chapel.
The chapel in which Father Prout officiated was by no means a
building of pretension. At that time the roof was out of repair, and,
in wet weather, acted as a gigantic shower-bath. The floor, then,
consisted of beaten earth, which was somewhat of a puddle
whenever the rains descended and the winds blew. The Cork ladies
soon found the chapel, entered it, and (accustomed to the rich
churches of their own persuasion) gazed in wonder on the humble,
unadorned place of worship in which they stood. It may literally be
said "in which they stood," for there were no pews, no chairs, not
even a solitary stool.
Presently the chapel began to fill, and "the pressure from without"
gradually drove the ladies nearer and yet nearer to the altar. At
length Father Prout entered in his clerical attire, and commenced the
service. In Catholic churches the priest officiates, during the early
part of the service, with his face to the altar, and his back to the
congregation. Thus, it happened that Prout never saw his Cork
friends until the time when he turned round to the congregation.
Then he beheld them, handsomely and fashionably attired, standing
up (for the floor was too puddled to allow them to soil their vesture
by kneeling, as every one else did), the gazed-at by all beholders,
looking and feeling the reverse of comfortable.
Father Prout immediately looked at his clerk, Pat Murphy,—an
original in his way,—caught his eye and his attention, and gently
inclining towards him, whispered, "send for three chairs for the
ladies." Pat, who was a little deaf, imperfectly caught his master's
words, and turned round to the congregation and roared out, "Boys!
his Reverence says, 'Three cheers for the ladies.'" The congregation,
obedient and gallant, gave three tremendous shouts, to the surprise
of the ladies and the horror of the priest. There was a good deal of
merriment when the mistake was explained, but to his dying day
Father Prout was reminded, whenever he visited Cork, of the "Three
cheers for the ladies."
Pat Murphy, his clerk, was quite a character. He affected big words,
and was mortally offended whenever any one called him clerk or
sexton. "I pity the weakness of your intellectual organization," he
would contemptuously exclaim. "If you had only brains enough to
distinguish B from a bull's foot, you would appreciate my peculiar
and appropriate official designation. The words 'clerk' and 'sexton'
are appellations which distinctify the menial avocations of persons
employed in heretical places of worship. My situation is that of
Sacristan and my responsible duty is to act as custodian of the
sacred utensils and vestments of the chapel."
Murphy had an exaggerated idea of the abilities of his principal, and
stoutly maintained that if the Pope knew what was good for the
Church, he would long since have elevated Father Prout to the
episcopal dignity. His chief regret, when dying, was, that he did not
survive to see this consummation.
Sometimes Pat Murphy would condescend to enter into a vivâ voce
controversy with one of the "heretics," (as he invariably designated
the Protestants,) on the comparative merits of the rival churches. His
invariable wind-up, delivered gravely and authoritatively, as a
clincher, to which he would permit no reply, was as follows:—"I
commiserate your condition, which is the result of your miserable
ignorance. Unfortunate individual! out of the New Testament itself I
can prove that your religion is but a thing of yesterday. With you
Protestants the Apostle Paul had not the most distant acquaintance,
whereas he corresponded with us of the Holy Roman Church. You
doubt it? Know you not that, from Corinth, he wrote an Epistle to the
Romans, and if the Protestants were in existence then, and known
to him, why did he not as well send an Epistle unto them?"
Father Prout was short and rotund. His Sacristan was tall and thin.
Immemorial usage permits the clerical cast-off garments to descend,
like heirlooms, to the parish clerk. Pat Murphy, in the threadbare
garments which erst had clothed the rotundity of Father Prout, was a
ludicrous looking object. The doctrine of compensation used to be
carried out, on such occasions, with more truth than beauty. The
waist of the priest's coat would find itself under Murphy's arms, the
wristbands would barely cover his elbows, and the pantaloons,
sharing the fate of the other garments, would end at his knees,
leaving a wide interval of calf visible to public gaze. On the other
hand, by way of equivalent, the garments would voluminously wrap
around him, in folds, as if they were intended to envelope not one
Pat Murphy, but three such examples of the mathematical definition,
"length without breadth." On one occasion I had the double
satisfaction of seeing Father Prout, like Solomon, in all his glory, with
Pat Murphy in full costume. It happened in this wise:
There was pretty good shooting about Watergrass-hill, and the
officers of an infantry regiment, who were quartered at Fermoy, at
the period to which I refer, had made Prout's acquaintance, while
peppering away at the birds, and had partaken of a capital
impromptu luncheon which he got up on the moment. Prout, it may
be added, was in the habit of receiving presents of game, fish and
poultry from his friends in Cork, (the mail-coaches and other public
conveyances passing his door several times every day,) and as long
as Dan Meagher, of Patrick-street, was in the wine-trade, be sure
that his friend, Father Prout, did not want good samples of the
generous juice of the grape. Of course, he also had a supply of real
potheen. Cellar and larder thus provided for, Prout was fond of
playing the host.
A great intimacy speedily sprung up between Prout and his military
friends, and he partook of numerous dinners at their mess in Fermoy
Barracks. At last, determined to return the compliment, he invited
them all to dine with him at Watergrass-hill. One of my own cousins,
who happened to be one of the guests, took me with him—on the
Roman plan, I presume, which permitted an invited guest to bring
his shade. I was a youngster at the time, but remember the affair as
if it were of yesterday.
If there was any anticipation of a spoiled dinner, it was vain. Prout,
who was on intimate terms with all his neighbours for half a dozen
miles round, had been wise enough to invoke the aid of the
Protestant rector of Watergrass-hill, who not only lent him plate,
china, and all other table necessaries, but—what was of more
importance—also spared him the excellent cook who, it was said,
could compose a dinner, in full variety, out of any one article of food.
Each of the officers was attended at table by his own servant, and
Pat Murphy, in full dress, officiated as servitor, at the particular
disposal of Father Prout himself.
The dinner was excellent,—well-cooked, well-served, and worthy of
praise for the abundance, variety, and excellence of the viands.
There was everything to be pleased with—nothing to smile at.
I beg to withdraw the last four words. There was Pat Murphy, in an
ex-suit of Prout's, looking such a figure of fun, that, on recalling the
scene now, I wonder how, one and all, we did not burst into a shout
of laughter when he first was presented to view. He looked taller,
and scraggier, and leaner than usual—his clothes appearing greater
misfits than ever! Prout, who kept his countenance remarkably well,
evidently saw and enjoyed the ludicrous appearance of his man. On
the other hand, the man, taking on himself the duties of Major
Domo, ordered the other attendants about in all directions,
muttering curses between his teeth whenever they did not do
exactly as he commanded. But everything went off gaily, and Prout's
rubicund face became redder and more radiant under the influence
of this success.
In the course of the entertainment, Father Prout, addressing his
attendant, said, "Pat, a glass of porter, if you please." The liquor was
poured, and, as it frothed in the glass, Prout raised it to his lips with
the words, "Thank you, Pat." Waiting until he had completed the
draught, Pat, in a tone of earnest remonstrance, said, "Ah, then,
your Reverence, why should you thank me for what's your own? It
would be decent for these genteels who are dining here, to thank
me for the good drink, but you've no right to do anything of the sort,
seeing that the liquor is your own. It is my supplication that you will
not do so again; there is an incongruity in it which I disrelish." We
had some difficulty in not laughing, but contrived to keep serious
faces during this colloquy.
The liberality of the little Padre had provided us with three courses,
and just as Pat Murphy was in the act of relieving a noble roasted
haunch of mutton, before his master, by a dish of snipe, he
happened to look out of the window and see one of his own familiar
associates passing along the street. Hastily flinging down the dish,
he threw up the window, and, kneeling down, with his long arms
resting on the sill, loudly hailed his friend, "Where are ye going,
Tom?" The answer was that a dance was expected in the
neighbourhood, and at which, of course, Pat would be "to the fore."
Now, the said Pat, very much like Ichabod Crane in figure, had a sort
of sneaking desire, like him, to be wherever pretty women were to
be seen. "No," said Pat, "I do not anticipate to be relieved in any
thing like proper time from attendance here this evening. His
Reverence, who has been ating and drinking, with remarkable
avidity, on the military officers down in Fermoy, is hospitable to-day,
and entertains the whole squad of them at dinner. To see them ate,
you'd think they had just got out of a hard Lent. 'Tisn't often, I dare
say, that they get such a feast. There's the mutton sent by
Chetwood of Glanmire; and the poultry by Cooper Penrose of Wood-
hill; and the lashings of game by Devonshire of Kilshanneck; and the
fruit by Lord Riversdale of Lisnegar—that is, by his steward, for 'tis
little his Lordship sees of the place that gives him a good six
thousand a year;—and the barrel of porter from Tommy Walker of
Fermoy; and the wine from red-faced Dan Meagher of Cork; and
everything of the best. Depend on it, the officers won't stir until they
have made fools of all the provender. By-and-bye, that the poor
mightn't have a chance of the leavings, they will be calling for grilled
bones, and devilled legs and gizzards. No, Tom, my mind misgives
me that I can't go to the dance this evening. Here's the officers, bad
'cess to them, that are sedentary fixtures until midnight."
This oration delivered,—and every one had been silent while Pat
Murphy was thus unburthening his mind,—he arose from his knees,
closed the window, and resumed his place behind Father Prout, with
"a countenance more of sorrow than of anger," calm and
unconcerned as if nothing had occurred out of the ordinary routine.
At that moment, Prout threw himself back on his chair, and laughed
until the tears rolled down his cheeks, and thus encouraged, the
company followed his example, and laughed also. When the mirth
had subsided, it was almost renewed by the solemn countenance of
Pat Murphy, grave rather than severe—a sort of domestic Marius
sitting, in sad contemplation, amid the ruins of Carthage.
Father Prout had rather a rough set of parishioners to deal with. He
could be, and was, very much of the gentleman, but it pleased him
to appear plain and unpolished to those among whom his lot was
cast. At times, when nothing else would do, he would address them,
in an exhortation, very much in the spirit of Swift's "if you like the
conditions, down with the dust!" At such times, Rabelais, "in his easy
chair," would have smiled, and Swift himself would have hailed Prout
as a congenial spirit.
I have a memorandum of one of these sermons. The object was to
collect some arrears of "dues" from certain non-paying parishioners,
(constituting rather a large portion of his congregation,) and I have
been told that the discourse was much to this effect:
FATHER PROUT'S SERMON.
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.
testbankbell.com