You are on page 1of 67

MATLAB for Engineers - eBook PDF

Visit to download the full and correct content document:


https://ebooksecure.com/download/matlab-for-engineers-ebook-pdf/
MATLAB® for Engineers
MATLAB® for Engineers
Sixth Edition

Holly Moore

Salt Lake Community College

Salt Lake City, Utah


Content Management: Dawn Murrin, Erin Ault

Content Production: Devanshi Tyagi

Product Management: Holly Stark

Product Marketing: Krista Clark

Rights and Permissions: Rimpy Sharma

Please contact https://support.pearson.com/getsupport/s/ with any

queries on this content.

Microsoft and/or its respective suppliers make no representations about

the suitability of the information contained in the documents and related

graphics published as part of the services for any purpose. All such

documents and related graphics are provided “as is” without warranty of

any kind. Microsoft and/or its respective suppliers hereby disclaim all

warranties and conditions with regard to this information, including all

warranties and conditions of merchantability, whether express, implied or

statutory, fitness for a particular purpose, title and non-infringement. In no

event shall Microsoft and/or its respective suppliers be liable for any

special, indirect or consequential damages or any damages whatsoever

resulting from loss of use, data or profits, whether in an action of contract,

negligence or other tortious action, arising out of or in connection with the

use or performance of information available from the services.

The documents and related graphics contained herein could include

technical inaccuracies or typographical errors. Changes are periodically

added to the information herein. Microsoft and/or its respective suppliers

may make improvements and/or changes in the product(s) and/or the

program(s) described herein at any time. Partial screen shots may be


viewed in full within the software version specified.

Microsoft and Windows are registered trademarks of the Microsoft

Corporation in the U.S.A. and other countries. This book is not sponsored

or endorsed by or affiliated with the Microsoft Corporation.

Copyright © 2023, 2018, 2015 by Pearson Education, Inc. or its

affiliates, 221 River Street, Hoboken, NJ 07030. All Rights Reserved.

Manufactured in the United States of America. This publication is

protected by copyright, and permission should be obtained from the

publisher prior to any prohibited reproduction, storage in a retrieval

system, or transmission in any form or by any means, electronic,

mechanical, photocopying, recording, or otherwise. For information

regarding permissions, request forms, and the appropriate contacts within

the Pearson Education Global Rights and Permissions department, please

visit www.pearsoned.com/permissions/.

Acknowledgments of third-party content appear on the appropriate page

within the text.

PEARSON is an exclusive trademark owned by Pearson Education, Inc. or

its affiliates in the U.S. and/or other countries.

Unless otherwise indicated herein, any third-party trademarks, logos, or

icons that may appear in this work are the property of their respective

owners, and any references to third-party trademarks, logos, icons, or

other trade dress are for demonstrative or descriptive purposes only. Such

references are not intended to imply any sponsorship, endorsement,

authorization, or promotion of Pearson’s products by the owners of such

marks, or any relationship between the owner and Pearson Education,

Inc., or its affiliates, authors, licensees, or distributors.

MATLAB® and Simulink® are registered trademarks of The MathWorks,

Inc., 3 Apple Hill Drive, Natick, MA 01760-2098.


Library of Congress Cataloging-in-Publication Data

Names: Moore, Holly, author.

Title: MATLAB® for Engineers / Holly Moore, Salt Lake Community

College.

Description: Sixth edition. | Hoboken : Pearson, [2023] | Includes index.

Identifiers: LCCN 2021051256 | ISBN 9780137627981

Subjects: LCSH: Engineering mathematics—Data processing. | MATLAB.

Classification: LCC TA345 .M585 2022 | DDC 620.001/51—dc23/eng/

20211117

LC record available at https://lccn.loc.gov/2021051256

ScoutAutomatedPrintCode

Rental:

ISBN-10: 0-13-762798-X

ISBN-13: 978-0-13-762798-1
Pearson’s
Commitment to Diversity,
Equity, and Inclusion
Pearson is dedicated to creating bias-free content that reflects the

diversity, depth, and breadth of all learners’ lived experiences.

We embrace the many dimensions of diversity, including but not limited to

race, ethnicity, gender, sex, sexual orientation, socioeconomic status,

ability, age, and religious or political beliefs.

Education is a powerful force for equity and change in our world. It has the

potential to deliver opportunities that improve lives and enable economic

mobility. As we work with authors to create content for every product and

service, we acknowledge our responsibility to demonstrate inclusivity and

incorporate diverse scholarship so that everyone can achieve their

potential through learning. As the world’s leading learning company, we

have a duty to help drive change and live up to our purpose to help more

people create a better life for themselves and to create a better world.

Our ambition is to purposefully contribute to a world where:

• Everyone has an equitable and lifelong opportunity to succeed through

learning.
• Our educational content accurately reflects the histories and lived

experiences of the learners we serve.

• Our educational products and services are inclusive and represent the

rich diversity of learners.

• Our educational content prompts deeper discussions with students

and motivates them to expand their own learning (and worldview).

Accessibility

We are also committed to providing products that are fully accessible to all

learners. As per Pearson’s guidelines for accessible educational Web

media, we test and retest the capabilities of our products against the

highest standards for every release, following the WCAG guidelines in


developing new products for copyright year 2022 and beyond.

You can learn more about Pearson’s commitment to accessibility at

https://www.pearson.com/us/accessibility.html

Contact Us

While we work hard to present unbiased, fully accessible content, we want

to hear from you about any concerns or needs with this Pearson product

so that we can investigate and address them.

Please contact us with concerns about any potential bias at https://

www.pearson.com/report-bias.html

For accessibility-related issues, such as using assistive technology

with Pearson products, alternative text requests, or accessibility

documentation, email the Pearson Disability Support team at


disability.support@pearson.com
Contents
About This Book xiii 

Dedication and Acknowledgments xvii 

1 About MATLAB 1 

1.1 What Is MATLAB? 1 

1.2 Student Edition of MATLAB 2 

1.3 How is MATLAB Used in Industry? 3 

1.4 Problem Solving in Engineering and Science 5 

2 MATLAB Environment 9 

2.1 Getting Started 9 

2.2 MATLAB Windows 11 

2.3 Solving Problems with MATLAB 17 

2.4 Saving Your Work 41 

Summary 53 

Key Terms 56 

Problems 56 

3 Built-In MATLAB Functions 64 

Introduction 64 

3.1 Using Built-In Functions 64 

3.2 Using the Help Feature 66 

3.3 Elementary Math Functions 67 

3.4 Trigonometric Functions 75 


3.5 Data Analysis Functions 80 

3.6 Random Numbers 100 

3.7 Complex Numbers 104 

3.8 Computational Limitations 108 

3.9 Special Values and Miscellaneous Functions 109 

Summary 111 

Key Terms 113 

Problems 114 

4 Manipulating MATLAB Arrays 121 

Introduction 121 

4.1 Manipulating Numeric Arrays 121 

4.2 Problems with Two Variables—Using Meshgrid 128 

4.3 Special Arrays 135 

4.4 Introduction to Character and String Arrays 141 

Summary 146 

Key Terms 147 

Problems 148 

5 Plotting 156 

Introduction 156 

5.1 Two-Dimensional Plots 156 

5.2 Subplots—Tiled Chart Layouts 173 

5.3 Other Types of Two-Dimensional Plots 176 

5.4 Three-Dimensional Plotting 193 

5.5 Editing Plots from the Menu Bar 200 


5.6 Creating Plots from the Workspace Window 202 

5.7 Saving Your Plots 203 

5.8 Other Plotting Options 203 

Summary 204 

Key Terms 206 

Problems 207 

6 User-Defined Functions 218 


Introduction 218 

6.1 Creating Function Files 218 

6.2 Subfunctions 238 

6.3 Creating Your Own Toolbox of Functions 243 

6.4 Anonymous Functions and Function Handles 245 

6.5 Function Functions 246 

Summary 247 

Key Terms 249 

Problems 249 

7 User-Controlled Input and Output 257 

Introduction 257 

7.1 User-Defined Input 257 

7.2 Output Options 262 

7.3 Graphical Input 276 

7.4 Reading and Writing Data from Files 277 

7.5 Debugging Your Code 280 

Summary 285 
Key Terms 286 

Problems 287 

8 Logical Functions and Selection Structures 291 

Introduction 291 

8.1 Relational and Logical Operators 292 

8.2 Flowcharts and Pseudocode 294 

8.3 Logical Functions 296 

8.4 Logical Indexing 303 

8.5 Selection Structures 307 

8.6 Debugging 324 

Summary 325 

Key Terms 326 

Problems 326 

9 Repetition Structures 341 

Introduction 341 

9.1 for Loops 342 

9.2 while Loops 350 

9.3 break and continue 358 

9.4 Midpoint Break Loops 359 

9.5 Nested Loops 363 

9.6 Improving the Efficiency of Loops 364 

Summary 367 

Key Terms 368 


Problems 369 

10 Matrix Algebra 374 

Introduction 374 

10.1 Matrix Operations and Functions 374 

10.2 Solutions of Systems of Linear Equations 396 

10.3 Special Matrices 409 

Summary 410 

Key Terms 412 

Problems 412 

11 Other Kinds of Arrays 420 

Introduction 420 

11.1 Numeric Data Types 421 

11.2 Character and String Data 427 

11.3 Symbolic Data 432 

11.4 Logical Data 432 

11.5 Sparse Arrays 434 

11.6 Categorical Arrays 434 

11.7 Time Arrays 435 

11.8 Multidimensional Arrays 439 

11.9 Cell Arrays 441 

11.10 Structure Arrays 443 

11.11 Table Arrays 449 

11.12 Timetable Arrays 458 

Summary 462 
Key Terms 464 

Problems 464 

12 Symbolic Mathematics 472 

Introduction 472 

12.1 Symbolic Algebra 472 

12.2 Solving Expressions and Equations 480 

12.3 Symbolic Plotting 490 

12.4 Units of Measurement 498 

12.5 Calculus 503 

12.6 Differential Equations 516 

12.7 Converting Symbolic Expressions to Anonymous Functions 519 

Summary 520 

Key Terms 522 

Problems 523 

13 Numerical Techniques 532 

13.1 Interpolation 532 

13.2 Curve Fitting 542 

13.3 Using the Interactive Fitting Tools 554 

13.4 Differences and Numerical Differentiation 557 

13.5 Numerical Integration 565 

13.6 Solving Differential Equations Numerically 570 

Summary 578 

Key Terms 581 

Problems 581 
14 Advanced Graphics 589 

Introduction 589 

14.1 Images 589 

14.2 Graphics Objects 604 

14.3 Animation 611 

14.4 Other Visualization Techniques 618 

14.5 Introduction to Volume Visualization 620 

Summary 625 

Key Terms 627 

Problems 627 

15 Simulink®— A Brief Introduction 630 

Introduction 630 

15.1 Applications 630 

15.2 Getting Started 631 

15.3 Solving Differential Equations with Simulink 639 

Summary 646 

Key Terms 646 

Problems 646 

Appendix A Special Characters, Commands, and Functions 651 

Appendix B Scaling Techniques 666 

Appendix C Annual Climatological Summary 669 

Appendix D Solutions to Practice Exercises

(Available at www.pearsonhighered.com/moore)
Index 671 
Dedication and
Acknowledgments

This project would not have been possible without the

support of both my family and colleagues. Thanks to

Mike, Heidi, Meagan, and David, and to my husband,


Dr. Steven Purcell. I also benefited greatly from the

suggestions for problems related to electricity from Lee

Brinton and Gene Riggs of the SLCC Electrical

Engineering Department. Their cheerful efforts to

educate me on the mysteries of electricity are much

appreciated. I’d also like to thank Quentin McRae, also

at SLCC, who made numerous suggestions that

improved the homework problems. And finally, Art Fox

has been my tireless colleague and collaborator for

almost 20 years and is responsible in large part for the

success of our MATLAB computing courses at SLCC—

especially the online versions.

This book is dedicated to my father, Professor George E.

Moore, who taught in the Department of Electrical

Engineering at the South Dakota School of Mines and

Technology for almost 20 years. Professor Moore earned

his college degree at the age of 54 after a successful

career as a pilot in the United States Air Force and was a

living reminder that you are never too old to learn. My

mother, Jean Moore, encouraged both him and her two

daughters to explore outside the box. Her loving

support made it possible for both my sister and I to


enjoy careers in engineering—something few women

attempted in the early 1970s. I hope that readers of this

text will take a minute to thank those people in their

lives who’ve helped them make their dreams come true.

Thanks Mom and Dad!


Chapter 1
About MATLAB
 Objectives

After reading this chapter, you should be able to:

• Describe what MATLAB is and why it is widely used in engineering

and science.

• Describe the advantages and limitations of the student edition of

MATLAB.

• Identify example applications where MATLAB is used in industry to

solve problems.

• Formulate problems using a structured problem-solving approach.


1.1 What is MATLAB?
MATLAB is a “multiparadigm ” programming language, which means it

can be used in several different ways to perform programming tasks.

Those tasks can range from something as simple as balancing your

checkbook to complex engineering modeling applications. The way you

approach the calculations required to complete these tasks may be

different, depending on your experience and personal preferences, the

number of calculations required, the amount of data involved,

mathematical limitations, the audience for the results, and many other

considerations.

Key Idea
MATLAB is a multiparadigm programming language.

MATLAB is a versatile language, but it can’t do everything. It is a large


application program  designed to optimize mathematical calculations;

number-crunching is where it shines. You wouldn’t want to use it to write

a word-processing program , for example. If you wanted to write an


operating system  or design software, C++, Java, or some other higher-

level language would be a better choice. In fact, MATLAB was originally

written in Fortran and then later rewritten in C. So why use MATLAB

instead of the underlying high-level language  for any programming

task? It is easier to formulate mathematical problems in MATLAB, the use

of array calculations makes repetitive calculations run faster in MATLAB

than in the underlying language, and there is easy access to graphics to

help you display your results.


Key Idea
MATLAB is optimized for array calculations.

Key Idea
MATLAB offers easy access to graphics.

There are several different ways to access MATLAB, which is produced by

the MathWorks. It is available in professional, student, and home versions.

The professional version is probably installed in your college or university

computer laboratory, but you may be able to download a copy if your

institution has a site license . It is also available online if your institution


has a license or if you have purchased either a student license or a home

license. With the online version, you can use MATLAB in a web browser 

without installing any software on your personal computer. MATLAB is

updated regularly; this textbook is based on MATLAB 9.10. If you are

using a different version, you may notice a difference in the layout of the

graphical user interface;  however, the differences in the coding

approaches should be minor.

The standard installation of MATLAB can solve a wide variety of technical

problems and is sufficient for many applications. However, additional

capability is available in the form of function  toolboxes. These


toolboxes  are purchased separately. If you have access to the complete

suite of toolboxes, you may be tempted to download everything—however,

the complete R2021b version of the software required almost 28 gigabytes

of memory. Future versions are sure to be larger. It would be wise to

carefully consider your computer’s memory storage limits and your

internet download speed before deciding which toolboxes to download.

You can find a complete list of the MATLAB product family at the

MathWorks website, www.mathworks.com.


Key Idea
MATLAB toolboxes offer additional capability and are

purchased separately.
1.2 Student Edition of MATLAB
The professional and student editions of MATLAB are very similar.

Beginning students probably won’t be able to tell the difference. Student

editions are available for Microsoft Windows, Mac, and Linux operating

systems, and can be purchased from college bookstores or online from

MathWorks at www.mathworks.com.

Key Idea
MATLAB is regularly updated.

MathWorks packages its software in groups called releases, and MATLAB


9.10 is featured, along with other products, such as Simulink, in Release

R2021b. New versions are released every six months. Students may

purchase just MATLAB, or a bundle that includes the following products:

• A single-user license, limited to students for use in their classwork

(The professional version is licensed either singly or to a group.)

• Control Systems Toolbox

• Curve Fitting Toolbox

• DSP System Toolbox

• Full MATLAB

• Image Processing Toolbox

• Instrument Control Toolbox

• Optimization Toolbox

• Parallel Computing Toolbox

• Signal Processing Toolbox

• Simulink

• Statistics and Machine Learning Toolbox


• Symbolic Math Toolbox

Toolboxes other than those included with the student edition may be

purchased separately. If you are using a professional installation of

MATLAB, all of the toolboxes available in the student edition may not be

available to you.

The biggest difference you should notice between the professional and

student editions is the command prompt, which is

>>

in the professional version, and

EDU>>

in the student edition.


1.3 How is MATLAB Used in
Industry?
The ability to use tools such as MATLAB is quickly becoming a

requirement for many engineering positions. A recent job search on

Monster.com found the following advertisement:

. . . is looking for a System Test Engineer with Avionics  experience.

Responsibilities include modification of MATLAB scripts , execution

of Simulink simulations, and analysis of the results data. Candidate

MUST be very familiar with MATLAB, Simulink, and C + + ⋯

This advertisement isn’t unusual. The same search turned up 771 different

companies that specifically required MATLAB skills for entry-level

engineers. Widely used in engineering and science fields, MATLAB is

particularly popular for electrical engineering applications. The sections

that follow outline a few of the many applications currently using

MATLAB.

Key Idea
MATLAB is widely used in engineering.

1.3.1 Electrical Engineering


MATLAB is used in electrical engineering for a wide variety of

applications. For example, Figure 1.1  includes several images created to

help visualize the arrangements of electromagnetic fields  in space and

time. These images represent real physical situations with practical


applications. Cellular communications, medical diagnostics, and home

computers are just a few of the technologies that exist thanks to our

understanding of this beautiful phenomenon.

Figure 1.1

Arrangements of electromagnetic fields. (a) surface plasmon  polariton;


(b) light scattering by a circular metal cylinder; (c) beam forming by a six-
element dipole array.

(Used with permission of Dr. James R. Nagel, University of Utah Department of Electrical and
Computer Engineering.)

Figure 1.1 Full Alternative Text 

1.3.2 Biomedical Engineering


Medical images are usually saved as dicom files (the Digital Imaging and

Communications in Medicine standard). Dicom files use the file extension

.dcm. The MathWorks offers an Image Processing Toolbox that can read

these files, making their data available to MATLAB. (The Image Processing

Toolbox is included with the student edition, and is optional with the

professional edition.) The Image Processing Toolbox also includes a wide

range of functions, many of them especially appropriate for medical

imaging. A limited MRI  data set that has already been converted to a
format compatible with MATLAB ships with the standard MATLAB

program. This data set allows you to try out some of the imaging functions

available both with the standard MATLAB installation and with the

expanded imaging toolbox, if you have it installed on your computer.

Figure 1.2  shows six images of horizontal slices through the brain based
on the MRI data set.

Figure 1.2

Horizontal slices through the brain, based on the sample data file included
with MATLAB.

Figure 1.2 Full Alternative Text 

The same data set can be used to construct a three-dimensional image,

such as either of those shown in Figure 1.3 . Detailed instructions on how

to create these images are included in the MATLAB tutorial, accessed from

the help button on the MATLAB toolbar.

Figure 1.3
Three-dimensional visualization of MRI data, based on the sample data set
included with MATLAB.

Figure 1.3 Full Alternative Text 

1.3.3 Fluid Dynamics


Calculations describing fluid velocities (speeds and directions) are

important in a number of different fields. Aerospace engineers in particular

are interested in the behavior of gases, both outside an aircraft or space

vehicle and inside the combustion chambers. Visualizing the three-

dimensional behavior of fluids is tricky, but MATLAB offers a number of

tools that make it easier. Figure 1.4  represents the flow-field calculation
results for a thrust-vector control  device as a quiver plot. Thrust-vector

control is the process of changing the direction in which a nozzle points

(and hence the direction a rocket travels) by pushing on an actuator (a

piston-cylinder device). The model in the figure represents a high-pressure

reservoir of gas (a plenum) that eventually feeds into the piston and thus

controls the length of the actuator.

Figure 1.4
Quiver plot of gas behavior in a thrust-vector control device.

Figure 1.4 Full Alternative Text 


1.4 Problem Solving in Engineering
and Science
A consistent approach to solving technical problems is important

throughout engineering, science, and computer programming disciplines.

The approach we outline here is useful in courses as diverse as chemistry,

physics, thermodynamics, and engineering design. It also applies to the


social sciences, such as economics and sociology. Different authors may

formulate their problem-solving schemes differently, but they all have the

same basic format:

• State the problem.

▪ Drawing a picture is often helpful in this step.

▪ If you do not have a clear understanding of the problem, you are

not likely to be able to solve it.

• Describe the input values (knowns) and the required outputs

(unknowns).

▪ Be careful to include units as you describe the input and output

values. Sloppy handling of units often leads to wrong answers.

▪ Identify constants you may need in the calculation, such as the

ideal gas constant and the acceleration due to gravity.

▪ If appropriate, label a sketch with the values you have identified,

or group them into a table.

• Develop an algorithm  to solve the problem. In computer


applications, this can often be accomplished with a hand example.

You’ll need to:

▪ Identify any equations relating the knowns and unknowns.

▪ Work through a simplified version of the problem by hand or with

a calculator.

• Solve the problem. In this book, this step involves creating a MATLAB

solution.
• Test the solution.

▪ Do your results make sense physically?

▪ Do they match your sample calculations?

▪ Is your answer really what was asked for?

▪ Graphs are often useful ways to check your calculations for

reasonableness.

Key Idea
Always use a systematic problem-solving strategy.

If you consistently use a structured problem-solving approach, such as the

one just outlined, you’ll find that “story” problems become much easier to

solve. Example 1.1  illustrates this problem-solving strategy.

Example 1.1 The Conversion of Matter To Energy

Albert Einstein (Figure 1.5 ) is arguably the most famous physicist

of the 20th century. He was born in Germany in 1879 and attended

school in both Germany and Switzerland. While working as a patent

clerk in Bern, he developed his famous theory of relativity. Perhaps

the best-known physics equation today is his

E = mc2.

Figure 1.5
Albert Einstein.

(GL Archive/Alamy Stock Photo)

This astonishingly simple equation links the previously separate

worlds of matter and energy, and can be used to find the amount of

energy released as matter is changed in form in both natural and

human-made nuclear reactions.

The sun radiates 385 × 1024 J / s of energy, all of which is generated

by nuclear reactions converting matter to energy. Use MATLAB and

Einstein’s equation to determine how much matter must be


converted to energy to produce this much radiation in one day.

1. State the problem

Find the amount of matter necessary to produce the amount

of energy radiated by the sun every day.

2. Describe the input and output

Input

Energy: E = 385 × 1024 J / s, which must be


converted into the total energy radiated
during one day

Speed of c = 3.0 × 108 m/ s


light:

Output

Mass m

in kg

3. Develop a hand example

The energy radiated in one day is

385 × 1024 J / s × 3600 s/ h × 24 h/ day × 1 day = 3.33 × 1031 J .

The equation E = mc2 must be solved for m and the values

for E and c substituted. Thus,

E
m=
c2
3.33 × 1031 J
m=
2
(3.0 × 108 m/ s)
= 3.7 × 1014 J / ( m 2/ s2) .

We can see from the output criteria that we want the mass in

kg, so what went wrong? We need to do one more unit

conversion:

1J = 1 kg m 2/ s2
J kg m 2/ s2
= 3.7 × 1014 × = 3.7 × 1014 kg
2 J
m 2/ s

4. Develop a MATLAB solution


At this point, you have not learned how to create MATLAB

code. However, you should be able to see from the following

sample code that MATLAB syntax is similar to that used in

most algebraic scientific calculators. MATLAB commands

are entered at the prompt (>>), and the results are reported

on the next line. The code is:

>> E=385e24 The user types in this


information
E =
3.8500e+026 This is the computer’s
response
>> E=E*3600*24
E =
3.3264e+031
>> c=3e8
c =
300000000
>> m=E/c^2
m =
3.6960e+014

From this point on, we will not show the prompt when

describing interactions in the command window.

5. Test the solution

The MATLAB solution matches the hand calculation, but do

the numbers make sense? Anything times 1014 is a really

large number. Consider, however, that the mass of the sun is

2 × 1030 kg. We can calculate how long it would take to


consume the mass of the sun completely at a rate of

3.7 × 1014 kg/ day. We have

Mass of t he sun
T ime =
Rat e of consumpt ion
2 × 1030 kg year
T ime = × = 1.5 × 1013 years.
14 365 days
3.7 × 10 kg/ day
That’s 15 trillion years! We don’t need to worry about the

sun running out of matter to convert to energy in our

lifetimes.
Key Terms
algorithm 

application program 

avionics 

electromagnetic fields 

function 

graphical user interface 

high-level computer language 

MRI 

multiparadigm 

operating system 

script 

site license 

surface plasmon 

thrust vector control 

toolbox 

web browser 

word-processing program 
Chapter 2
MATLAB Environment
 Objectives

After reading this chapter, you should be able to:

• Start the MATLAB program and solve simple problems in the

command window.

• Identify and use the various MATLAB windows.

• Identify and use the basic data types used in MATLAB.

• Define and use simple arrays.

• Name and use variables.

• Use the correct order of operation rules to solve problems using

MATLAB.

• Identify the differences between scalar, array, and matrix


calculations in MATLAB.

• Express numbers in either floating-point or scientific notation.

• Adjust the format used to display numbers in the command

window.

• Save the value of variables used in a MATLAB session.

• Save a series of commands in a MATLAB program, either as a script

(M-file) or as a live script (MLX-file).

• Use Section mode.


2.1 Getting Started
Using MATLAB for the first time is easy; mastering it can take years. In

this chapter, we will introduce you to the MATLAB environment and show

you how to perform basic mathematical computations. After reading this

chapter, you should be able to start using MATLAB for homework

assignments or on the job. Of course, you will be able to do more as you

complete the rest of the chapters.

Because the procedure for installing MATLAB depends upon your

operating system and your computing environment, we will assume that

you have already installed MATLAB on your computer, that you are

working in a computing laboratory with MATLAB already installed, or are

using MATLAB online. To start MATLAB in either the Windows or Mac

environment, double-click on the icon on the desktop, or use the start


menu to find the program. In the UNIX environment, type Matlab at the

shell prompt . No matter how you start it, once MATLAB opens, you
should see the MATLAB prompt (>> or EDU>>), which tells you MATLAB

is ready for you to enter a command. When you have finished your

MATLAB session, you can exit MATLAB by typing quit or exit at the

MATLAB prompt. MATLAB also uses the standard Windows menu bar, so

you can exit the program by selecting the close icon (x) at the upper right-

hand corner of the screen. The default MATLAB screen, which opens each

time you start the program, is shown in Figure 2.1 . (There are minor
differences in the MATLAB desktop, depending on the release.)

Figure 2.1
MATLAB 2021a opening window. The MATLAB environment consists of a
number of windows, three of which open in the default view. Others open
as needed during a MATLAB session.

Figure 2.1 Full Alternative Text 

To start using MATLAB, you only need to be concerned with the

command window (in the center of the screen). You can perform

calculations in the command window in a manner similar to the way you

perform calculations on a scientific calculator. Even most of the syntax is

the same. For example, to compute the value of 5 squared, type the

command

5^2

The following output will be displayed:

ans =
25

Or, to find the value of cos(π), type

cos(pi)
which results in the output

ans =
-1

Key Idea
MATLAB uses the standard algebraic rules for order of
operation.

MATLAB uses the standard algebraic rules for order of operation, which

becomes important when you chain calculations together. These rules will

be discussed in Section 2.3.3 . Notice that the value of pi is built into


MATLAB, so you do not have to enter it yourself.

Hint
You may think some of the examples are too simple to type in

yourself—that just reading the material is sufficient. However,

you will remember the material better if you both read it and

type it!

Before going any further, try Practice Exercise 2.1 .

Practice Exercise 2.1


Type the following expressions into MATLAB at the command prompt,

and observe the results. The correct answers can be found on the Pearson
website at https://www.pearsonhighered.com/moore.

1. 5 + 2

2. 5*2

3. 5/2

4. 3 + 2*(4 + 3)

5. 2.54*8/2.6

6. 6.3 − 2.1045

7. 3.6^2

8. 1 + 2^2

9. sqrt(5)

10. cos(pi)

Hint
You may find it frustrating to learn that when you make a

mistake, you cannot just overwrite your command after you

have executed it. This occurs because the command window is

creating a list of all the commands you have entered. You

cannot “un-execute” a command, or “un-create” it. What you

can do is enter the command correctly, then execute your new

version. MATLAB offers several ways to make this easier for you.

One way is to use the arrow keys, usually located on the right-

hand side of your keyboard. The up arrow, ↑, allows you to move

through the list of commands you have executed. Once you find

the appropriate command, you can edit it, then execute your

new version.
2.2 MATLAB Windows
MATLAB uses several display windows. The three-column view, shown in

Figure 2.1 , includes in the middle, a large command window  ; located

on the right, the workspace window , and located on the left the current

folder window . In addition, the command history window ; document

windows , graphics windows,  and editing windows  will

automatically open when needed. Each will be described in the sections

that follow. MATLAB also includes a built-in help tutorial that can be

accessed from the toolstrip  by selecting the question mark icon, as


shown in Figure 2.1 . To personalize your desktop, you can resize any of

these windows, stack them on top of each other, close the ones you are

not using, or “undock” them from the desktop by using the “Show

Workspace Actions” menu located in the upper right-hand corner of each

window. You can restore the default configuration by selecting Layout on

the toolstrip, then selecting Default, or you can add additional windows by

selecting Layout and choosing the windows you would like to see.

2.2.1 Command Window


The command window is located in the center pane of the three-column

view of the MATLAB screen, as shown in Figure 2.1 . The command

window offers an environment similar to a scratch pad. Using it allows you

to save the values you calculate, but not the commands used to generate

those values. If you want to save the command sequence, you will need to

use the editing window to create a MATLAB program. MATLAB programs

can be stored as either scripts  (in M-files ) or live scripts  (in MLX-

files ). Both approaches are valuable. Before we introduce MATLAB

programs, we will concentrate on using the command window.


Key Idea

The command window is similar to a scratch pad.

2.2.2 Command History


The command history window records the commands issued in the

command window. It does not open in the default view but you can add it

to your desktop by selecting Layout → Command History and checking

“docked.” The examples in this book will show the Command History in a

docked configuration. When you exit MATLAB, or when you issue the clc

command, the command window is cleared, but the command history

retains a list of all your commands. You may clear the command history

from the “Show Command History Actions” drop-down menu, located in

the upper right-hand corner of the window. If you work on a public

computer, as a security precaution, MATLAB’s defaults may be set to clear

the history when you exit MATLAB. If you entered the earlier sample

commands listed in this book, notice that they are repeated in the

command history window. This window is valuable for a number of

reasons, including allowing you to review previous MATLAB sessions. It

can also be used to transfer commands to the command window. For

example, first clear the contents of the command window by typing

clc

Key Idea

The command history records all of the commands

issued in the command window.


This action clears the command window but leaves the data in the

command history window intact. You can transfer any command from the

command history window to the command window by double-clicking

(which also executes the command), or by clicking and dragging the line

of code into the command window. Try double-clicking

cos(pi)

in the command history window. The command is copied into the

command window and executed. It should return

ans =
-1

Now click and drag

5^2

from the command history window into the command window. The

command will not execute until you hit Enter, and then you will get the

result:

ans =
25

You will find the command history useful as you perform more
Another random document with
no related content on Scribd:
place.

Richard Whitmore returned without having seen either Colonel Pease or his
daughter, so was unable to answer the volley of questions by which he was
assailed.

"Miss Pease was comfortably established at the hotel selected by her brother,
and had received a telegram announcing his arrival. She hoped to see him
almost immediately. I thought it better not to intrude upon such a meeting by
staying until he came," he replied.

Miss Pease wrote letters which showed that she was brimming over with
gladness; but as the days went on a difficulty arose as to her return to Mere
Side.

"My brother has much business to attend to, and will have a great deal of
travelling before he can settle down. There is no one but myself to look after
Norah. What can I do but stay with the child?"

"Bring her here, I should say," suggested Mina. "By all accounts she knows
very little of her native country, for she went to India a tiny child, came back,
lost her mother, and since then has wandered to and fro on the earth under
her aunt's wing. May she come here, Dick, and enjoy a summer holiday in
England?"

"I can have no objection, dear. In fact, it is the best possible solution to the
difficulty. Then we shall get our dear little house-mother back again, and as
soon as Colonel Pease can spare time for a rest he shall come too, if he will.
Mere Side will be a real home for him amongst you girls, until he can fix on
one for himself. He means to buy a handsome place somewhere."

Miss Pease was delighted when the cordial invitation came, and actually
written in Gertrude's hand. She was longing for the dear niece to meet the
girls to whom she was so warmly attached, and she was utterly weary of hotel
life after a fortnight's experience, and with but little of her brother's society,
owing to unavoidable causes. So she sent a grateful acceptance on North's
behalf, and herself carried to Mere Side a message from Colonel Pease, who
promised to spend his first spare week there.

The little lady was warmly welcomed by the Whitmore girls on her return, and
her niece was also received in a manner that charmed both. They were all,
however, surprised to find that the new guest, though a girl, was about Mina's
age, instead of Molly's.
The latter expressed what the rest felt when, after embracing Miss Pease with
equal vigour and affection, she exclaimed, "Why, your niece is a grown-up
young lady. I thought she was a girl like me, and that we should all call her
Norah."

"She will be very much distressed if you call her anything else," said the girl
herself. "I am very sorry for the misapprehension, but you must please not
blame my aunt for it. The mistake she made was not a wilful one."

"The fact is, Molly dear, that I never calculated on Norah being grown-up any
more than you did, but kept picturing her as very much the same as when I
last saw her, forgetting that Time had not stood still with the child any more
than with the rest of us."

They felt that Miss Pease had been herself mistaken, and when she added,
"You must not like my Norah any less on account of her aunt's blunder," a
chorus of welcoming words came from the girls, after which the young guest
was conveyed to her room.

"I think she is one of the most charming young creatures I ever saw," said Jo,
and Mina echoed the expression.

"What do you think of Norah, Gertrude?"

"I quite agree with you both," was the answer; and in her heart she added, "I
wish she were not so charming."

Richard was absent when the arrival took place, but on his return in the early
evening, he glanced towards the doorway, and saw not only his pet Molly on
the look-out for his coming, but a sort of glorified Molly near her.

It was a girl with hair of the same shade and a very fair complexion, but taller
and slenderer than his robust young sister. He could see the perfect profile,
and was sure the eyes were beautiful, though he could not discern their
colour. But whilst the features were so fine and delicately cut, there was
nothing of the mere statue-like beauty in the face as a whole. On the contrary,
those who might be at first attracted by the almost perfect features, would
forget these in the greater beauty of expression and the wonderful charm of
manner which Norah Pease possessed.

Richard Whitmore did not see all this at once. But he noted the figure of a girl
in a simple dress of dainty Dacca muslin, only relieved by pale blue bows, and
he thought it exactly suited the place. Norah was not looking in his direction,
but towards something which Molly was pointing out in the distance, and he
slackened his steps in order to take in the sweet picture more fully.

Miss Pease saw him coming, and met him at the door to exchange greetings,
and to be welcomed back by Richard himself. As they crossed the hall
together, Molly, who had become aware of her brother's presence, rushed to
meet him.

"Come, Dick," she said, "and be introduced to Norah. She is older than I am
by more than three years, and not a schoolgirl, but she is just as nice."

Miss Pease was about to introduce Norah to her host in due form, but Molly
spared her the trouble by saying, "Norah, this is Brother Dick. He is such a
darling, and so is she, Dick. You are sure to like one another. Are they not,
Miss Pease?" turning to her elder friend.

"Indeed I hope so," said Richard; and, quite naturally, Norah echoed the wish.

"I can hardly feel strange here," she added, "for my aunt has written so much,
and, since we met, talked so much about every one at Mere Side, that I
almost thought I was going to meet five more cousins, and had a sense of
extra riches in consequence."

"Cousins do not seem such very near relatives after all," said Molly, in a
meditative tone. "Sisters are better. I should like you for one, Norah."
Miss Pease was just a little scandalized at Molly's freedom of speech, and
said, "My dear, you talk too fast. I am afraid Richard spoils you too much."

But there was no trace of self-consciousness on Norah's face as she thanked


Molly for her willingness to adopt her as a relative on such very short
acquaintance. Then Richard, Miss Pease, and she talked on quite
unrestrainedly, and the girl was enthusiastic about the loveliness around her.
Somehow, the aunt and niece drifted into the angle window, while Dick stood
just within, his arm round Molly, and told his young guest the names of the
hills which bounded the view, and various other particulars about the
landscape before them.

"This window is the most charming nook I ever saw," said Nora. "I can
scarcely bear to leave it. And what a wealth of roses you have! The varieties
seem endless."

"If you are not too tired, will you come and look at them before dinner? You
want some flowers to wear, do you not? My sisters always like to have them
and to choose for themselves."

"That is the best of all," said Norah. "I would rather have a knot of wild-flowers
that I gathered for myself than the finest bouquet that could be bought ready
put together by an accomplished gardener."

She turned to leave the recess, but at the instant something struck violently
against the glass and startled her. On looking she could see nothing.

"Do not be alarmed," said Richard. "This is a thing which, unfortunately, often
happens. A poor bird has flown against the pane, and probably wounded itself
so badly that it will die. As the creatures can see through the glass, they
cannot understand that it offers a solid obstacle to their flight, and many are
killed in this way. It is the only drawback to my enjoyment of this window. Will
you not come out this way?" And Richard stepped out through the open sash,
and offered his hand to assist Norah in following.

There upon the ground, feebly fluttering, lay a fine thrush, wounded to death.
Tears sprang into Norah's eyes as she saw it, but, happily, the pains of the
injured bird were not of long duration. A moment after she first saw it the
movement ceased.

Richard picked up the dead thrush, and gently stroked its glossy feathers,
then laid it down amongst some shrubs, saying, "It shall be buried by and by.
You may think me sentimental for a man, but I do not like to cover the poor
little body with earth whilst it is warm with the life that has but just fled."

"I think you feel just as I do. Why should a man be less pitiful than a girl?"
replied Norah.

Richard smiled in reply, and led the way to the roses, for his guest to make
choice amongst them. At first he had felt sorry that Norah should be with only
her aunt and Molly, beside himself, for the other girls were engaged at a tennis
party, to which they had been invited before they knew when Miss Pease
would return. But he never forgot that evening which seemed to bring the girl
guest and himself so near together, and that night he dreamed of the slender
white-robed figure framed by the angle window.

Day followed day, and each developed some new charm in Norah. She had
travelled much, and had a well-stored mind, without the smallest taint of
pedantry. She was a born musician, but though her voice was well cultivated,
she owed less to her teachers than to her natural gifts, and when she sang,
none could help listening with delight.

The Whitmore girls loved her. Even Gertrude felt the spell, for with all Norah
was so sweet, frank, tender, and natural, that she won hearts without effort.
She had won one that hitherto had never been stirred in like manner, for
Richard Whitmore had given to Norah all the love of which his large heart was
capable.

Outsiders began to smile as they saw the young master of Mere Side so
constant in his attendance on his graceful guest. Miss Sharp found something
new to talk about, and whispered to gossips like herself, that any one could
see what Miss Pease had brought Norah to Saltshire for. She had fished for
an invitation for her niece in order to get her a rich husband. How hard it
would be for those four girls to give place to a chit like that!

Gentle Miss Pease had her qualms of conscience lest she might be misjudged
in this matter, though she knew her brother's only child would be a rich
heiress, and no unsuitable mate in that respect for Richard Whitmore.

And Gertrude! She was not blind. She guessed her brother's secret, but said
nothing, though a fierce combat was going on within her. Self was battling
against her love for Richard, and that which Norah had wrung from her in spite
of her will. She felt how well suited they were to each other, and yet she could
not endure the idea of Richard taking to himself a wife.
The other girls had no such feelings, but would have welcomed Norah as a
sister with open arms.

Week followed week, and it was near the end of August. Still Norah stayed on
at Mere Side, and waited in expectation of her father's coming, and still he
was prevented from joining her there. His letters were frequent and full of
regrets, though he expressed the hope that present self-denial would lead to
satisfactory results, and that when these business matters were settled, a
future of rest would be before him.

One morning, however, Norah received a letter which scattered dismay


amongst the family at Mere Side.

She could not bear to tell the contents, but passed it for her aunt to read
aloud, and Miss Pease began, "My dearest Eleanor."

"I thought your name was just Norah," said Molly. "I am always called so,
because—"

Someone entered at the moment, and stopped the girl from telling why her
name had been thus abridged, and Miss Pease continued—

"I am really grieved that after all I cannot at present join you at Mere Side, and
have the pleasure of personally thanking Mr. Whitmore and his sisters for all
their kindness and of making their acquaintance. I must hope for this at some
future time."

"You, dear Eleanor, must come to me with as little delay as possible. I should
like you to meet me on Thursday, and on Saturday I purpose going on to
Paris, where your aunt and cousins now are. A family matter requires that we
should meet. Indeed, she wants my help, and, after all her goodness to you, it
would ill become me to hesitate, if I can be of use to her. Nelly and Beatrice
are in a state of wild delight at the prospect of seeing you."

"Your aunt's maid, Carter, has been visiting her old mother in Lincolnshire, and
I have arranged that she shall bring you from Mere Side, or rather from
Salchester, where she will meet with you, travel to town with you, and cross
with us to the Continent. This plan will prevent your causing any
inconvenience to your aunt."

There were further messages of thanks, regards, and regrets, and then the
letter ended, amid a chorus of groans from the listeners.
Norah's face had grown pale, and Richard's had on it an expression of pain
that was unmistakable.

He had waited, like the honourable man he was, for the coming of Colonel
Pease before speaking to Norah. He thought it would not be right to declare
his affection for the daughter until the father had seen him, and had an
opportunity of judging of his character.

He must not speak now, for this was Wednesday, and on the morrow the girl
was to leave. The bustle of preparation had to be got over, and at ten o'clock
in the morning Norah must be ready to depart.

So much had to be crowded into so short a time that there was little leisure for
uttering vain regrets, though a running fire of these was kept up on all sides
through the day and during the gathering together of Norah's belongings.

"Shall you have any spare time?" asked Richard at luncheon. "Or will it be all
bustle until you step into the carriage?"

"I shall have the whole evening," replied Norah; "all the time, I mean, from four
o'clock. I could not do without a last happy night to look back upon. I can
never thank you all for your kindness to me."

"Thank us by coming back and bringing your father as soon as possible. For
the present, I, for one owe you much, Norah; so the balance is really on the
other side. My home was never so graced before," he added, with a smile and
a look which made a flush cover the girl's fair face, "or seemed so bright a
place to me."

But she looked bravely up at him in return, and said—

"I will certainly come back to Mere Side, if I may, and bring my father too. You
ought to know each other. You only need to meet to be friends."

That afternoon they all had early tea on the terrace, and as they sat there the
old swallows circled round and round, feeding their young ones in the air, and
exercising them preparatory to the long flight before them. Down they came,
skimming the surface of the lake, which was all aglow with the rays of the
declining sun, dipping in its waters, and then gathering on the roof to plume
themselves after their bath.

"The swallows are getting ready for flight, like you, Norah," said Richard. "A
little while and they will all be gone. See, that is a hawk in the distance. I hope
he will not carry off any fledgling to-night."

"You know everything," she replied. "Birds, bees, trees, flowers are all familiar.
You only need a glance to name them."

"I have lived among them always. A country life has interest enough for me;
but I do sometimes wish to see more than these familiar objects, and, but for
an outcry among the girls, I should have joined a scientific expedition this last
spring. I could not leave the mother awhile back, or my sisters in their sorrow.
Perhaps I may give up the idea altogether," he added in a musing fashion,
"though there is such an expedition annually in connection with a society to
which I belong."

"I hope you will not be away when I—when my father comes to Mere Side,"
said Norah.

And Dick responded emphatically—

"I certainly shall not."

Later on in the twilight Norah sat at the piano and sang one song after
another, and then they stole an hour from sleep, and all talked of the happy
days they had spent together, and of their hope of meeting again. At the same
time on the following evening the swallows were skimming to and fro, but
Norah was gone, and the house seemed empty to its master, though all the
rest were left. But as he sat in the library, with his head leaning on his hand,
Richard saw neither books nor aught around him.

He was picturing that slender, white-robed figure as he first saw it in the


doorway. He heard none of the sounds going on around, though the tennis-
players were on the lawn and the bold song of the robins came from every
bush. What he heard was a sweet voice flooding the room with a richer song,
and one that spoke more to his heart than theirs.

And Richard smiled to himself as he said, "The seat in the angle window, the
mother's seat, will be filled again, and I shall hear the dear voice that makes
my heart thrill as no other can, in place of the echo which memory gives me
now. For I felt her little hand tremble in mine, and though she said 'good-bye'
in a brave voice to all the rest, she could not say it to me, though her lips
parted and closed. I had her last look, and tears were shining in her eyes as
she gave it. They are speaking eyes, and they said to me, 'I am sorry to go,
but I will not forget my promise. I will come again.'"
CHAPTER VI.
THE FRAME HAS A PICTURE ONCE MORE.

NORAH wrote as soon as possible to tell of her arrival at Paris, and pour forth
on the same sheet her regrets at parting from the Whitmores, and her
pleasure in being with all her kith and kin. At first there seemed a prospect of
their returning to England; but later on, instead of hearing that a time was
fixed for their coming, news arrived of a contrary character. The doctors
advised Colonel Pease to winter at Cannes, in order that after so many years
spent in India, he might not be too suddenly exposed to the severity of the
season in England.

Richard Whitmore heard this, and began to meditate on the possibility of


taking Miss Pease and his sisters to spend the winter in the Riviera, but he
decided to let January come first, and then to journey South for the three
following months.

Once more came a message from the angle window which put an end to his
plans and froze to the death the glad hopes that he had been nourishing in his
heart.

Gertrude was sitting there with Miss Pease, reading a letter aloud, when he
entered the morning-room. She was not very fond of pet names, and often
called her sisters by theirs at fall length instead of using the diminutives, Mina
and Jo, and roused Molly's wrath by calling her Florence Mary. Since she had
been aware that Norah was only short for Eleanor, Gertrude usually spoke of
their late guest by her full name also.

As Richard entered the room he heard his sister say, "So Eleanor is actually
engaged to Sir Edward Peyton. Is it not rather a sudden affair?"

"Perhaps it may be deemed so in respect to the engagement itself, but they


have been long acquainted. While Norah was here she often spoke of his
frequent visits and attentions when we were alone, but so long as there was
nothing definite it was scarcely likely she would allude to such things before
others."

Richard paused a moment to recover himself after the blow. Then he


advanced towards Miss Pease, saying, "I was not an intentional
eavesdropper, but I heard the news of your niece's engagement, and I
suppose I must congratulate you on the event."

"Yes, Eleanor is engaged," said the little lady, all sympathetic smiles and
blushes. "Sometimes I think when such events occur, condolences would be
more fitting for those they leave behind. When there is but a single parent and
few children, or only one, a break brings pain as well as pleasure, even
though caused by marriage."

Richard begged Miss Pease to give his congratulatory messages, and then
stole away into the library to think over what he had heard, and find comfort as
best he might.

There was only one picture that came constantly before him, and that was the
angle window without an occupant, and a dying bird on the terrace below.

And Richard whispered to himself, "Just another wounded bird. I could almost
wish that I, too, had been injured even unto death. If it were not that I am
needed, specially by Molly, I should say it in earnest. As it is, I must run away,
lest the rest should see the wound."

Richard's mind was promptly made up. There was to be an expedition for the
purpose of observing a total eclipse of the sun, visible in Southern latitudes,
but not in England. He announced his intention of joining it, pleaded that he
wanted a shake-up, that he was growing old and rusty by dint of over-petting
and self-indulgence; and, in short, that he must go.

Before Miss Pease received another letter conveying a message of thanks for
his congratulations, Richard had completed his arrangements and was on his
way to Mauritius.

Whilst there he saw in the "Times," for February 27, an announcement of the
marriage, at Cannes, of Sir Edward Peyton, Bart., and Eleanor Pease. It was
simply worded, and as the "Queen" did not fall into his hands, Richard missed
many details about dresses, bridesmaids, etc., some of which might have
proved interesting.
He wondered a little that almost nothing was said in subsequent home letters
about this marriage. Miss Pease did just mention that Eleanor's wedding had
taken place, and there were allusions in some of his sisters' epistles to the
good match made by her niece, but Norah, as the Norah of Mere Side, was
not mentioned, or only in the most cursory way.

"Perhaps they guess," thought Richard, "and are silent for my sake. Thank
God, for Norah's! From all I have been able to ascertain she has married a
good man, and I pray that she may be happy. I would not grudge her to the
husband of her choice, but somehow I cannot believe that any tie existed
when she was with us. If I had only spoken, or gone when she did to meet her
father—but it is too late."

It was not until the May twelve months after leaving home that Richard
Whitmore set foot in England again.

He joined one scientific party after another, and went to and fro, adding much
to his store of knowledge, and finding in change of scene and the habit of
close observation, which gave him work for every day, the best remedy for the
wound which healed but slowly.

Then he had to come home, to open his hands for more wealth. A distant
cousin had left him thirty thousand pounds. When the news reached him he
said, "This, divided into four and added to the little belonging to the girls, will
give each of them ten thousand pounds, for the Maynards do not want it.
There will be more for them by and by, from their bachelor brother, for I shall
never marry now."

He did not tell them this, or even about the legacy at first. He had to hear of all
that had passed during his absence, to note that Molly, now turned seventeen,
was more like Norah Pease, slenderer and more thoughtful-looking than of
old.

It was Dick's absence that had made her the last. Little Miss Pease's hair was
greyer, but it just suited her delicately fresh complexion. Nina and Jo had
altered less than Molly, but Gertrude was the most changed of all.

There was a new light in her eyes, a softer flush on her cheek, a gentleness of
manner foreign to the old Gertrude. Molly's welcome was not more hearty
than hers, or her sisterly embrace more tender or more entirely voluntary than
was Gertrude's.
Nobody had told Richard anything, but he looked at his eldest sister and
guessed her secret rightly.

The girl had given her heart to a good, but not a rich man, one who at first
feared to offer his own to Miss Whitmore, of Mere Side, lest he should be
suspected of seeking a rich bride whose wealth would make amends for his
own small means.

For once Miss Sharp's tongue did good service without its being intended. Her
keen eyes, ever on the watch, detected something in Gertrude's manner
favourable to Mr. Kemble, of whose views she decided there could be no
doubt.

"He is in the Civil Service, and has an income of three hundred a year," said
Miss Sharp. "I dare say he thinks Gertrude Whitmore is an heiress, but I shall
open his eyes, and show that proud minx what he is really looking after."

Miss Sharp carried out her resolution, and managed to let Mr. Kemble's sister
and niece, visitors in the neighbourhood, know the exact amount to which
Miss Whitmore was entitled under her father's will. The result astonished her.

Instead of packing up and departing at once, Mr. Kemble manifested the


greatest delight. He would have shrunk from the heiress, but he dared to ask
the girl he loved to share his lot, when he found out that there was not much
disparity in their means, and none in social standing; and she accepted him
with this proviso, that Richard must give his consent, though she was of age.

Gertrude told her brother this, sitting in the angle window, and with the moon
shining in thereat.

Dick kissed her, rejoiced with her, and told her there was no need to wait for
the advance of salary which Kemble was sure of in another year.

"True hearts should not be parted without a needs-be, my dear, and none
exists in your case," he said. Then he told her how he had always put by a
considerable portion of his income, in order that his sisters might not be
dowerless maidens.

"I counted on this sort of thing coming to one of you at a time, you know, and I
was fairly ready for your first turn, my dear, before something else happened,
which has given me at a stroke enough for you all."
He told her of the legacy, and the share he had mentally appropriated to
herself, then added, "As I am a cut-and-dried old bachelor, there will be more
for you in the long run."

He was not prepared for what followed.

Gertrude broke into a flood of passionate tears and sobs, and between these
she cried, "Dick, dear brother Dick, can you forgive me? I do not deserve
anything from you. I have been hard and selfish and ungrateful. I have tried to
make the others so, and cared nothing for your happiness, only how I could
keep all good things to myself. It was when I learned to love Bertram that I
knew what I had done to you."

The girl sank on her knees and hid her tearful face in her hands as she bowed
her head over Dick's lap, and her frame shook with sobs.

Love had conquered at last, as he always believed it would, and Richard's


face looked beautiful in the moonlight, as he bent over his sister and insisted
on raising her from the ground and drawing her head on his breast.

"You do forgive me, Dick. Your kind touch tells me so without words; but
please listen, I want you to know everything—" and the girl went on and laid
bare all the envy, ingratitude, and selfishness that had begun during that visit
to the Tindalls, and how these things had grown and for a long time influenced
her life for evil. "Then," she said, "you were so persistently loving that I began
to see the beauty of your life and disposition, and to loathe the ugliness of my
own—till Norah came."
Richard started at the mention of that name, and Gertrude felt his heart beat
fuller and faster.

"No one, not even I, could help loving Norah," she said, "and often I thought
what a perfect mate she would be for you, dear Dick; but I could not endure
the idea of her coming here as mistress and turning us all out of Mere Side. I
thought you cared for her, and she for you, but nothing came of it, only I was
glad when she went away, though I expected you and she would soon meet
again. You would have done so if you had not set out for Mauritius, for we
were invited to the wedding, only we did not go as you were absent."

"How could I have gone?" asked Dick, with a groan of anguish that went to the
listener's heart and told her something of what he had suffered.

"Then you did think it was Norah who married Sir Edward Peyton. I thought
you misunderstood, and yet I purposely held my tongue. I know what my
silence has done. I felt it when I realised what it would be if I were called on to
part with Bertram. You will never forgive me, never."

"For pity's sake tell me what you mean, Gertrude! I am not often so impatient,
but suspense will drive me mad. Is Norah married?"

"No, Dick, neither has she ever been engaged. Do you remember that
morning when Miss Pease was reading the colonel's letter, in which he called
his daughter 'Eleanor'? Nora was going to explain why she was never
addressed by it at her aunt's, but someone interrupted. She told me
afterwards that Eleanor was her grandmother's name, and that her elder
cousin bore it as well as herself. To distinguish between them, one was called
Nelly; that was the girl whom Miss Pease described as having been 'all
elbows' when she was just in her teens, and the other, our Eleanor, was Norah
to everybody. Nelly is Lady Peyton, and Norah is Norah Pease to-day."

An irrepressible thanksgiving broke from Richard's lips, and confirmed


Gertrude's conviction, whilst it increased her penitence.

"You must know all," she added. "All the rest believed that you knew which of
the girls was engaged to Sir Edward Peyton. I led them to think so, without
directly saying it; and though they had thought you cared for Norah, when you
went away so suddenly they concluded either that they had made a mistake
or that she had refused you. This is why they scarcely named her in letters."
"Are Colonel Pease and Norah in England?" asked Richard, in a voice unlike
his own, so moved was he.

"Yes; and they are coming here to-morrow. They were to have come together
so long ago, but they have been wintering abroad and travelling about with the
other family ever since."

There was a short silence, and again Gertrude faltered out—

"Can you forgive me, now you know all?"

"Thank God, I can, as I hope to be forgiven. He has overruled all for good—
even my rashness and blindness."

For a little moment Richard still held the weeping girl to his breast, and then
he kissed her once more, and, gently placing her on the seat whence he had
risen, left her alone in the moonlight.

The next day brought Norah and her father, and the first sight of the dear fair
face told Richard as plainly as words that she had come back unchanged, and
was glad to be there.

A few more happy days, and then Richard told the story of his love, and knew
that the treasure he desired above all others was his very own, with her
father's full consent.

He spoke and she listened, in the fittest place of all—the angle window, which
is no longer a frame without a picture. A white-robed figure sits on what was
once the mother's seat, and gives her husband an answering smile when he
looks in that direction from amongst the roses.

Colonel Pease has bought a fine estate in Saltshire, with a house on it ready
to his hand, and his gentle little sister presides over his domestic
arrangements.

Gertrude's home is in the outskirts of London; Mina will soon follow her sister's
example, and go to a new nest. The other girls will do as they have done
since Dick's marriage—flit between Mere Side and Overleigh, the colonel's
home; for the old soldier is never happier or Miss Pease more in her element
than when they have young faces about them.

It is said that Miss Sharp has greatly affected the society of Miss Pease since
she began her rule at Overleigh; but there is no fear for the colonel; he is too
old a soldier.

Brother Dick is as truly blessed as his unselfish nature deserves to be, now he
has quite recovered from the wound he received through the angle window.
A MERE FLIRTATION

CHAPTER I.

"IT seems strange that Dr. Connor should advise your going away again in
such lovely weather, and from a place to which other people come in search
of health. He might let you have a little peace."

So spoke Norah Guiness to Jeannie Bellew, an only child, a probable heiress,


and the object of enough thought, care, and indulgence to spoil a much finer
nature than she was gifted with.

"It is always a doctor's way. He must order something different from what you
have, however good that may be. I have everything that money can buy, and
instead of being allowed to enjoy it in peace, am sent hither and thither at the
doctor's will. Look at me, Norah. Am I like an invalid?"

Thus appealed to, Norah surveyed Jeannie as she lay back in a folding-chair
and challenged her scrutiny with a half-defiant air.

Truly there was nothing of an invalid about the girl. There was a rich colour on
her fair face, her figure was symmetrical, and the shapely hand on which her
curly head partly rested was plump and well-rounded. Norah thought there
was no trace of illness, and said so.

"The doctor should know what is best," she replied; "but as an invalid you
appear to me an utter fraud."

A ringing, musical laugh greeted these words, then Jeannie started from her
seat, kissed Norah, declared she always was a dear, sensible darling, whose
judgment was worth that of all the doctors put together, danced round the
room, and finally dropped panting into her seat again, with a considerably
heightened colour.

Norah noticed that Jeannie's hand was pressed to her side, and looked grave.
"Are you wise to indulge in such violent exercise?" she asked.

"Perhaps not, though it is only the having been pampered and waited on hand
and foot that has made me so susceptible. I must really begin to live like other
girls now I am so well again," said Jeannie.

"Only do not make such a sudden start. Have you any pain?"

"Not a bit, now. I had a little twinge or two, but it is all gone. The strongest girl
would have felt as much if she had been prancing round as I did a minute ago.
I am as well as you are, Norah. It is downright wicked of Doctor Connor to say
that I must have another change for a month or so, and then he will decide
about next winter. As though one lost nothing by leaving a home like mule with
all its comforts. I have often thought that the loss of them counterbalanced the
good done by the 'entire change' the doctors are so fond of ordering. If I could
take Benvora and all belonging to it, Jet included, away with me, I should care
less. And I would have you, Norah, if I could."

"That is impossible, dear. I am quite indispensable at home. But there is Jack


Corry. You will want him most of all, now your engagement is a settled thing."

"Want Jack with me!" exclaimed Jeannie. "Why, Norah, what can have put
such an absurd notion into your head? If you realised my feelings the least
little bit, you would know that the sweet drop in my cup of banishment from
Ballycorene is the thought that I shall leave Jack Corry behind me. He bores
me to death. He follows me like a lapdog, gives me no chance of wishing to
see him, for he is here so often that I am at my wits' end to get rid of him half
the time. Jack Corry, indeed!" And Jeannie gave her pretty head a toss, as
though she and the individual in question had neither thought nor wish in
common.

Norah looked utterly bewildered, and heard without understanding her friend's
words.

"I thought you cared so much for Jack," she said. "If not, why did you act in
such a way as to make him think you did? 'Why did you accept his offer, and
allow your engagement to be announced, if—"

Norah hesitated to put her thoughts into words. She was true to the core
herself, and infinitely above the petty vanity and cruel selfishness combined
which make up the character of a flirt—vanity, which is ever craving for
admiration, and never satisfied with what it gets; selfishness, that cares only
for gratifying the whim of the moment, without heeding what the amusement
may cost some true heart; vanity, that loves to parade the homage that is
rendered, yet only values it so far as it can be displayed and utilised to
advance its own importance, or to while away time that would otherwise hang
heavily; selfishness, that having had its turn served, its little day of triumph,
never asks whether the moths that fluttered round had merely sunned
themselves in the light and suffered no harm, or whether they had been
cruelly scorched whilst suspecting none.

Hard hearts are like diamonds. The flirt's weapons glance harmlessly aside
from them and leave no wound, as the best-tempered tool leaves no scratch
on the surface of the precious stone. But those same weapons have pierced
many a true and tender heart, and virtually killed its faith in womanly truth, and
taught it to doubt the possibility of honest girlish affection.

It seemed too dreadful for Norah to associate the idea of vanity and
selfishness with her friend Jeannie, a girl just eighteen, and looking even
younger, with her fair face and childish head covered with a crop of short
curls. Yet as she gave a mental glance at the past she felt that Jeannie's
actions and words belied each other.

Jack Corry had long been deemed quite first favourite in the neighbourhood.
He was bright, kindly. To young and old alike, he was ever ready to render a
service, and people used to look at him and say that this was his one fault. He
was the same to all, and no person could detect any sign of preference
towards any of his fair neighbours.

Jeannie Bellew had spent two winters in the Riviera. Whether there now
existed any cause for anxiety on her behalf, there had been enough to justify
the fears of her parents and her own banishment.

A sharp attack of inflammation of the lungs, brought on, if truth must be told,
by her own wilfulness, had left the girl without absolute disease, but extremely
sensitive to every change of temperature. After her second winter in the
South, she had returned home with greatly improved strength and looks, but
in other respects rather changed than improved.

Jeannie, the little schoolgirl, with her artless country manners and winsome
ways, was gone, and in her stead there returned to Ballycorene one who was
a girl in age and looks, but who brought with her more knowledge of the world
than all her feminine neighbours put together could boast of.

Mrs. Bellew had accompanied her daughter on both occasions, and a middle-
aged, trusty servant waited on the two. But the mother dreaded the loneliness
of life in apartments, where everything and every person were strange around
them, and so the pair spent the two winters in a large hotel, and gained many
experiences which the younger especially would have been much better
without.

Before Jeannie's reappearance, Ballycorene gossips had begun to couple the


name of Jack Corry with that of Norah Guiness, and to say that at last the way
to his heart had been discovered. Also that if he had the luck to gain Norah's,
he would win the greatest treasure that could enrich his life and brighten a
home, though she would be almost a dowerless maiden.

Perhaps it was because no word or act of Norah's gave Jack Corry cause to
think she bestowed a thought upon him, that he began to devote much
thought to her. She practised no little coquettish airs, did not pretend to shun
him, in order to hire him to seek her. She met him, as she did others, with the
bright smile, the honest look devoid of all self-consciousness, the kindly
greeting which was natural in one whom he had known all his life, and no
more.

No girl looked on Norah as a possible rival. All regarded her as a true-hearted


friend, and saw in her a self-devoting daughter, the one comfort of her father's
life, and a sister almost worshipped by his three motherless lads. None could
accuse her of striving to attract Jack Corry, and so, when it seemed that he
was likely to be attracted, all the girls with one consent voted, "Better Norah
than anyone else."

Then Jeannie Bellew came back to Benvora, changed as aforesaid, a


fashionable young lady instead of a simple country girl, and yet with the power
to act the latter character to perfection when it suited the whim of the moment.
She was prettier than ever, and had acquired an ease and grace of manner
which, together with an almost inexhaustible wardrobe, threw all the country
girls into the shade.

Jeannie's father was very rich; sole owner of a vast manufacturing concern,
which in his skilful hands was always growing in value.

In what way could wealth be better applied than in surrounding his only child
with every luxury that it could purchase? Mr. Bellew was a good master, and
paid his hands liberally. No man ever applied to him in vain if help was wanted
for any good object, and so, as he was generous to all beside, was he likely to
stint where Jeannie was concerned?

You might also like