0% found this document useful (0 votes)
25 views54 pages

Instant Download Essential MATLAB For Engineers and Scientists 6th Edition Edition Hahn PDF All Chapter

ebook

Uploaded by

dulazewoning
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views54 pages

Instant Download Essential MATLAB For Engineers and Scientists 6th Edition Edition Hahn PDF All Chapter

ebook

Uploaded by

dulazewoning
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Full download ebook at ebookmass.

com

Essential MATLAB for engineers and scientists 6th


edition Edition Hahn

For dowload this book click link below


https://ebookmass.com/product/essential-matlab-
for-engineers-and-scientists-6th-edition-edition-
hahn/

OR CLICK BUTTON

DOWLOAD EBOOK

Download more ebook from https://ebookmass.com


More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Essential MATLAB for engineers and scientists Sixth


Edition. Edition Hahn

https://ebookmass.com/product/essential-matlab-for-engineers-and-
scientists-sixth-edition-edition-hahn/

Essential MATLAB for engineers and scientists 7th


Edition Edition Hahn

https://ebookmass.com/product/essential-matlab-for-engineers-and-
scientists-7th-edition-edition-hahn/

Essential MATLAB for engineers and scientists 7th


Edition Hahn B.D.

https://ebookmass.com/product/essential-matlab-for-engineers-and-
scientists-7th-edition-hahn-b-d/

Essential MATLAB for Engineers and Scientists Brian D.


Hahn & Daniel T. Valentine

https://ebookmass.com/product/essential-matlab-for-engineers-and-
scientists-brian-d-hahn-daniel-t-valentine/
MATLAB for Engineers 6th Edition Holly Moore

https://ebookmass.com/product/matlab-for-engineers-6th-edition-
holly-moore/

Statistics for Engineers and Scientists, 6th Edition


William Navidi

https://ebookmass.com/product/statistics-for-engineers-and-
scientists-6th-edition-william-navidi-2/

Statistics For Engineers and Scientists 6th Edition


William Navidi

https://ebookmass.com/product/statistics-for-engineers-and-
scientists-6th-edition-william-navidi/

MATLAB Programming for Engineers 6th Edition Stephen J.


Chapman

https://ebookmass.com/product/matlab-programming-for-
engineers-6th-edition-stephen-j-chapman/

Applied Numerical Methods with MATLAB for Engineers and


Scientists, 5th Edition Steven C. Chapra

https://ebookmass.com/product/applied-numerical-methods-with-
matlab-for-engineers-and-scientists-5th-edition-steven-c-chapra/
Essential MATLAB
for Engineers and Scientists
This page intentionally left blank
Essential MATLAB
for Engineers and Scientists
Sixth Edition

Brian H. Hahn
Daniel T. Valentine

AMSTERDAM • BOSTON • HEIDELBERG • LONDON


NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Academic Press is an imprint of Elsevier
Academic Press is an imprint of Elsevier
50 Hampshire Street, 5th Floor, Cambridge, MA 02139, United States
525 B Street, Suite 1800, San Diego, CA 92101-4495, United States
The Boulevard, Langford Lane, Kidlington, Oxford OX5 1GB, United Kingdom
125, London Wall, EC2Y, 5AS, United Kingdom

Copyright © 2017, 2013, 2010 Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved.
Copyright © 2007, 2006, 2002 Brian D. Hahn and Daniel T. Valentine. Published by Elsevier Ltd.

MATLAB® is a trademark of The MathWorks, Inc. and is used with permission.


The MathWorks does not warrant the accuracy of the text or exercises in this book.
This book’s use or discussion of MATLAB® software or related products does not constitute endorsement
or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the
MATLAB® software.

No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form
or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior
written permission of the publisher.

Permissions may be sought directly from Elsevier’s Science & Technology Rights Department in Oxford,
UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333, E-mail: [email protected]. You may
also complete your request online via the Elsevier homepage (http://www.elsevier.com), by selecting
“Support & Contact” then “Copyright and Permission” and then “Obtaining Permissions.”

Library of Congress Cataloging-in-Publication Data


A catalog record for this book is available from the Library of Congress.

British Library Cataloguing-in-Publication Data


A catalogue record for this book is available from the British Library.

ISBN: 978-0-08-100877-5

For information on all Academic Press publications


visit our website at https://www.elsevierdirect.com

Publisher: Todd Green


Acquisition Editor: Stephen Merken
Editorial Project Manager: Nate McFadden
Production Project Manager: Stalin Viswanathan
Designer: Matthew Limbert

Typeset by VTeX
Contents

PREFACE .............................................................................................................xv

Part 1 Essentials................................................................. 1
CHAPTER 1 Introduction............................................................................... 3
1.1 Using MATLAB..............................................................................5
1.1.1 Arithmetic .........................................................................5
1.1.2 Variables............................................................................7
1.1.3 Mathematical functions ...................................................8
1.1.4 Functions and commands ...............................................8
1.1.5 Vectors...............................................................................9
1.1.6 Linear equations.............................................................11
1.1.7 Tutorials and demos.......................................................12
1.2 The desktop ................................................................................13
1.2.1 Using the Editor and running a script ..........................13
1.2.2 Help, publish and view ...................................................16
1.2.3 Symbolics and the MuPAD notebook APP....................18
1.2.4 Other APPS .....................................................................23
1.2.5 Additional features .........................................................23
1.3 Sample program ........................................................................25
1.3.1 Cut and paste..................................................................25
1.3.2 Saving a program: script files .......................................27
Current directory ................................................................................28
Running a script from the current folder browser ..........................29
1.3.3 A program in action........................................................29
Summary ....................................................................................30
Exercises.....................................................................................31

CHAPTER 2 MATLAB Fundamentals ......................................................... 33


2.1 Variables .....................................................................................33
2.1.1 Case sensitivity ...............................................................34
2.2 The workspace ...........................................................................34
2.2.1 Adding commonly used constants to the workspace ..35
2.3 Arrays: Vectors and matrices....................................................36
2.3.1 Initializing vectors: Explicit lists ...................................36
v
vi Contents

2.3.2 Initializing vectors: The colon operator ........................37


2.3.3 The linspace and logspace functions.........................38
2.3.4 Transposing vectors .......................................................39
2.3.5 Subscripts .......................................................................39
2.3.6 Matrices ..........................................................................40
2.3.7 Capturing output ............................................................40
2.3.8 Structure plan.................................................................41
2.4 Vertical motion under gravity....................................................42
2.5 Operators, expressions, and statements .................................44
2.5.1 Numbers .........................................................................45
2.5.2 Data types .......................................................................45
2.5.3 Arithmetic operators......................................................46
2.5.4 Operator precedence .....................................................46
2.5.5 The colon operator .........................................................47
2.5.6 The transpose operator .................................................47
2.5.7 Arithmetic operations on arrays ...................................48
2.5.8 Expressions.....................................................................49
2.5.9 Statements......................................................................49
2.5.10 Statements, commands, and functions........................50
2.5.11 Formula vectorization ....................................................51
2.6 Output..........................................................................................54
2.6.1 The disp statement........................................................54
2.6.2 The format command ....................................................55
2.6.3 Scale factors ...................................................................56
2.7 Repeating with for.....................................................................57
2.7.1 Square roots with Newton’s method ............................58
2.7.2 Factorials! .......................................................................59
2.7.3 Limit of a sequence ........................................................59
2.7.4 The basic for construct .................................................60
2.7.5 for in a single line..........................................................61
2.7.6 More general for ...........................................................61
2.7.7 Avoid for loops by vectorizing!......................................62
2.8 Decisions.....................................................................................64
2.8.1 The one-line if statement ............................................64
2.8.2 The if-else construct...................................................66
2.8.3 The one-line if-else statement ..................................67
2.8.4 elseif .............................................................................67
2.8.5 Logical operators ...........................................................68
2.8.6 Multiple ifs versus elseif ...........................................69
2.8.7 Nested ifs ......................................................................70
2.8.8 Vectorizing ifs?..............................................................71
2.8.9 The switch statement....................................................71
2.9 Complex numbers......................................................................72
Summary ....................................................................................74
Exercises.....................................................................................76

CHAPTER 3 Program Design and Algorithm Development ..................... 83


3.1 The program design process.....................................................84
Contents vii

3.1.1 The projectile problem ...................................................87


3.2 Programming MATLAB functions .............................................92
3.2.1 Inline objects: Harmonic oscillators.............................92
3.2.2 MATLAB function: y = f (x ).............................................93
Summary ....................................................................................96
Exercise.......................................................................................96

CHAPTER 4 MATLAB Functions and Data Import-Export Utilities.......... 99


4.1 Common functions.....................................................................99
4.2 Importing and exporting data..................................................104
4.2.1 The load and save commands....................................104
4.2.2 Exporting text (ASCII) data...........................................104
4.2.3 Importing text (ASCII) data ..........................................105
4.2.4 Exporting binary data...................................................105
4.2.5 Importing binary data...................................................106
Summary ..................................................................................106
Exercises...................................................................................106

CHAPTER 5 Logical Vectors ..................................................................... 109


5.1 Examples ..................................................................................110
5.1.1 Discontinuous graphs ..................................................110
5.1.2 Avoiding division by zero ..............................................111
5.1.3 Avoiding infinity.............................................................112
5.1.4 Counting random numbers .........................................113
5.1.5 Rolling dice ...................................................................114
5.2 Logical operators .....................................................................114
5.2.1 Operator precedence ...................................................116
5.2.2 Danger...........................................................................116
5.2.3 Logical operators and vectors.....................................117
5.3 Subscripting with logical vectors............................................118
5.4 Logical functions ......................................................................119
5.4.1 Using any and all ........................................................120
5.5 Logical vectors instead of elseif ladders.............................121
Summary ..................................................................................123
Exercises...................................................................................124

CHAPTER 6 Matrices and Arrays ............................................................. 127


6.1 Matrices ....................................................................................127
6.1.1 A concrete example......................................................127
6.1.2 Creating matrices.........................................................129
6.1.3 Subscripts .....................................................................129
6.1.4 Transpose......................................................................130
6.1.5 The colon operator .......................................................130
6.1.6 Duplicating rows and columns: tiling .........................133
6.1.7 Deleting rows and columns .........................................134
6.1.8 Elementary matrices....................................................135
6.1.9 Specialized matrices....................................................136
6.1.10 Using MATLAB functions with matrices .....................137
viii Contents

6.1.11 Manipulating matrices .................................................138


6.1.12 Array (element-by-element) operations on matrices138
6.1.13 Matrices and for ..........................................................139
6.1.14 Visualization of matrices .............................................140
6.1.15 Vectorizing nested fors: loan repayment tables .......140
6.1.16 Multi-dimensional arrays ............................................142
6.2 Matrix operations .....................................................................143
6.2.1 Matrix multiplication....................................................143
6.2.2 Matrix exponentiation ..................................................145
6.3 Other matrix functions.............................................................146
6.4 Population growth: Leslie matrices .......................................146
6.5 Markov processes ....................................................................150
6.5.1 A random walk..............................................................150
6.6 Linear equations ......................................................................152
6.6.1 MATLAB’s solution .......................................................153
6.6.2 The residual ..................................................................154
6.6.3 Over-determined systems ...........................................154
6.6.4 Under-determined systems ........................................155
6.6.5 Ill conditioning ..............................................................155
6.6.6 Matrix division...............................................................156
6.7 Sparse matrices .......................................................................158
Summary ..................................................................................160
Exercises...................................................................................161

CHAPTER 7 Function M-files.................................................................... 163


7.1 Example: Newton’s method again ..........................................163
7.2 Basic rules ................................................................................165
7.2.1 Subfunctions .................................................................170
7.2.2 Private functions ..........................................................170
7.2.3 P-code files ...................................................................170
7.2.4 Improving M-file performance with the profiler ........171
7.3 Function handles......................................................................171
7.4 Command/function duality......................................................173
7.5 Function name resolution .......................................................174
7.6 Debugging M-files....................................................................174
7.6.1 Debugging a script .......................................................174
7.6.2 Debugging a function ...................................................176
7.7 Recursion..................................................................................176
Summary ..................................................................................178
Exercises...................................................................................179

CHAPTER 8 Loops ..................................................................................... 181


8.1 Determinate repetition with for .............................................181
8.1.1 Binomial coefficient .....................................................181
8.1.2 Update processes .........................................................182
8.1.3 Nested fors ..................................................................184
8.2 Indeterminate repetition with while ......................................184
8.2.1 A guessing game ..........................................................184
Contents ix

8.2.2 The while statement....................................................185


8.2.3 Doubling time of an investment ..................................185
8.2.4 Prime numbers ............................................................187
8.2.5 Projectile trajectory......................................................188
8.2.6 break and continue.....................................................190
8.2.7 Menus............................................................................190
Summary ..................................................................................191
Exercises...................................................................................192

CHAPTER 9 MATLAB Graphics................................................................. 197


9.1 Basic 2-D graphs......................................................................197
9.1.1 Labels............................................................................198
9.1.2 Multiple plots on the same axes .................................199
9.1.3 Line styles, markers and color....................................200
9.1.4 Axis limits......................................................................200
9.1.5 Multiple plots in a figure: subplot..............................202
9.1.6 figure, clf and cla.....................................................203
9.1.7 Graphical input .............................................................203
9.1.8 Logarithmic plots .........................................................203
9.1.9 Polar plots.....................................................................204
9.1.10 Plotting rapidly changing mathematical functions:
fplot .............................................................................205
9.1.11 The property editor.......................................................206
9.2 3-D plots ...................................................................................206
9.2.1 plot3 .............................................................................206
9.2.2 Animated 3-D plots with comet3 .................................207
9.2.3 Mesh surfaces ..............................................................207
9.2.4 Contour plots ................................................................209
9.2.5 Cropping a surface with NaNs ......................................211
9.2.6 Visualizing vector fields ...............................................211
9.2.7 Visualization of matrices .............................................212
9.2.8 Rotation of 3-D graphs.................................................213
9.3 Handle graphics .......................................................................214
9.3.1 Getting handles ............................................................214
9.3.2 Graphics object properties and how to change them215
9.3.3 A vector of handles.......................................................217
9.3.4 Graphics object creation functions .............................218
9.3.5 Parenting.......................................................................218
9.3.6 Positioning figures .......................................................219
9.4 Editing plots..............................................................................220
9.4.1 Plot edit mode...............................................................220
9.4.2 Property Editor .............................................................221
9.5 Animation..................................................................................222
9.5.1 Animation with Handle Graphics.................................222
9.6 Color etc....................................................................................225
9.6.1 Colormaps.....................................................................225
9.6.2 Color of surface plots...................................................226
9.6.3 Truecolor .......................................................................228
x Contents

9.7 Lighting and camera ................................................................228


9.8 Saving, printing and exporting graphs ...................................229
9.8.1 Saving and opening figure files ...................................229
9.8.2 Printing a graph............................................................229
9.8.3 Exporting a graph .........................................................229
Summary ..................................................................................230
Exercises...................................................................................231

CHAPTER 10 Vectors as Arrays and Other Data Structures.................... 235


10.1 Update processes.....................................................................235
10.1.1 Unit time steps .............................................................236
10.1.2 Non-unit time steps .....................................................238
10.1.3 Using a function............................................................239
10.1.4 Exact solution ...............................................................241
10.2 Frequencies, bar charts and histograms ...............................242
10.2.1 A random walk..............................................................242
10.2.2 Histograms ...................................................................243
10.3 Sorting.......................................................................................244
10.3.1 Bubble Sort ...................................................................244
10.3.2 MATLAB’s sort .............................................................246
10.4 Structures .................................................................................247
10.5 Cell arrays ................................................................................249
10.5.1 Assigning data to cell arrays .......................................249
10.5.2 Accessing data in cell arrays.......................................250
10.5.3 Using cell arrays ..........................................................251
10.5.4 Displaying and visualizing cell arrays ........................252
10.6 Classes and objects .................................................................252
Summary ..................................................................................253

CHAPTER 11 Errors and Pitfalls ................................................................ 255


11.1 Syntax errors ............................................................................255
11.1.1 Incompatible vector sizes ............................................256
11.1.2 Name hiding..................................................................256
11.2 Logic errors ..............................................................................256
11.3 Rounding error .........................................................................257
Summary ..................................................................................258
Chapter exercises ....................................................................258

Part 2 Applications ..........................................................261


CHAPTER 12 Dynamical Systems .............................................................. 263
12.1 Cantilever beam .......................................................................265
12.2 Electric current ........................................................................266
12.3 Free fall .....................................................................................269
12.4 Projectile with friction..............................................................278
Summary ..................................................................................281
Exercises...................................................................................282

CHAPTER 13 Simulation ............................................................................. 283


Contents xi

13.1 Random number generation ...................................................283


13.1.1 Seeding rand.................................................................284
13.2 Spinning coins ..........................................................................284
13.3 Rolling dice ...............................................................................285
13.4 Bacteria division.......................................................................286
13.5 A random walk .........................................................................286
13.6 Traffic flow ................................................................................288
13.7 Normal (Gaussian) random numbers ....................................291
Summary ..................................................................................291
Exercises...................................................................................292

CHAPTER 14 Introduction to Numerical Methods.................................... 295


14.1 Equations ..................................................................................295
14.1.1 Newton’s method .........................................................295
14.1.2 The Bisection method ..................................................297
14.1.3 fzero .............................................................................299
14.1.4 roots .............................................................................299
14.2 Integration ................................................................................300
14.2.1 The Trapezoidal rule ....................................................300
14.2.2 Simpson’s rule..............................................................301
14.2.3 quad ...............................................................................302
14.3 Numerical differentiation ........................................................302
14.3.1 diff ...............................................................................303
14.4 First-order differential equations ...........................................304
14.4.1 Euler’s method .............................................................304
14.4.2 Example: bacteria growth............................................305
14.4.3 Alternative subscript notation.....................................307
14.4.4 A predictor-corrector method .....................................307
14.5 Linear ordinary differential equations (LODEs) .....................308
14.6 Runge-Kutta methods .............................................................309
14.6.1 A single differential equation ......................................309
14.6.2 Systems of differential equations: chaos ...................310
14.6.3 Passing additional parameters to an ODE solver ......312
14.7 A partial differential equation .................................................314
14.7.1 Heat conduction............................................................314
14.8 Complex variables and conformal mapping ..........................317
14.9 Other numerical methods .......................................................319
Summary ..................................................................................320
Exercises...................................................................................321

CHAPTER 15 Signal Processing ................................................................. 325


15.1 Harmonic analysis ...................................................................326
15.2 Fast Fourier Transform (FFT)..................................................331

CHAPTER 16 SIMULINK Toolbox............................................................. 337


16.1 Mass-spring-damper dynamic system ..................................342
16.2 Bouncing ball dynamic system ...............................................345
16.3 The van der Pol oscillator........................................................347
xii Contents

16.4 The Duffing oscillator ..............................................................350


Exercises...................................................................................351

CHAPTER 17 Symbolics Toolbox ................................................................ 355


17.1 Algebra......................................................................................356
17.1.1 Polynomials ..................................................................357
17.1.2 Vectors...........................................................................359
17.1.3 Matrices ........................................................................360
17.2 Calculus ....................................................................................363
17.3 Laplace and Z transforms .......................................................366
17.4 Generalized functions..............................................................367
17.5 Differential equations ..............................................................369
17.6 Implementation of funtool, MuPAD and help.........................370
17.6.1 The funtool ....................................................................370
17.6.2 The MuPAD notebook∗ and Symbolic help.................370
Exercises...................................................................................373
APPENDIX A Syntax: Quick Reference ...................................................... 375
A.1 Expressions ..............................................................................375
A.2 Function M-files .......................................................................375
A.3 Graphics ....................................................................................375
A.4 if and switch...........................................................................376
A.5 for and while...........................................................................377
A.6 Input/output..............................................................................377
A.7 load/save..................................................................................378
A.8 Vectors and matrices ...............................................................378
APPENDIX B Operators .............................................................................. 381
APPENDIX C Command and Function: Quick Reference......................... 383
C.1 General-purpose commands ..................................................383
C.1.1 Managing variables and the workspace .....................383
C.1.2 Files and the operating system...................................383
C.1.3 Controlling the Command Window .............................384
C.1.4 Starting and quitting MATLAB.....................................384
C.2 Logical functions ......................................................................384
C.3 MATLAB programming tools...................................................384
C.3.1 Interactive input............................................................385
C.4 Matrices ....................................................................................385
C.4.1 Special variables and constants..................................385
C.4.2 Time and date ...............................................................385
C.4.3 Matrix manipulation .....................................................385
C.4.4 Specialized matrices....................................................386
C.5 Mathematical functions ...........................................................386
C.6 Matrix functions .......................................................................387
C.7 Data analysis ............................................................................387
C.8 Polynomial functions ...............................................................387
C.9 Function functions ...................................................................387
C.10 Sparse matrix functions ..........................................................388
C.11 Character string functions ......................................................388
Contents xiii

C.12 File I/O functions ......................................................................388


C.13 2D graphics...............................................................................388
C.14 3D graphics...............................................................................389
C.15 General......................................................................................389
APPENDIX D Solutions to Selected Exercises .......................................... 391
INDEX ............................................................................................................... 403
This page intentionally left blank
Preface

The main reason for a sixth edition of Essential MATLAB for Engineers and Scien-
tists is to keep up with MATLAB, now in its latest version (9.0 Version R2016a).
Like the previous editions, this one presents MATLAB as a problem-solving
tool for professionals in science and engineering, as well as students in those
fields, who have no prior knowledge of computer programming.
In keeping with the late Brian D. Hahn’s objectives in previous editions, the
sixth edition adopts an informal, tutorial style for its “teach-yourself” ap-
proach, which invites readers to experiment with MATLAB as a way of discov-
ering how it works. It assumes that readers have never used this tool in their
technical problem solving.
MATLAB, which stands for “Matrix Laboratory,” is based on the concept of
the matrix. Because readers will be unfamiliar with matrices, ideas and con-
structs are developed gradually, as the context requires. The primary audience
for Essential MATLAB is scientists and engineers, and for that reason certain ex-
amples require some first-year college math, particularly in Part II. However,
these examples are self-contained and can be skipped without detracting from
the development of readers’ programming skills.
MATLAB can be used in two distinct modes. One, in keeping the modern-age
craving for instant gratification, offers immediate execution of statements (or
groups of statements) in the Command Window. The other, for the more pa-
tient, offers conventional programming by means of script files. Both modes
are put to good use here: The former encouraging cut and paste to take full
advantage of Windows’ interactive environment. The latter stressing program-
ming principles and algorithm development through structure plans.
Although most of MATLAB’s basic (“essential”) features are covered, this book
is neither an exhaustive nor a systematic reference. This would not be in keep-
ing with its informal style. For example, constructs such as for and if are not
always treated, initially, in their general form, as is common in many texts, but
are gradually introduced in discussions where they fit naturally. Even so, they
xv
xvi Preface

are treated thoroughly here, unlike in other texts that deal with them only su-
perficially. For the curious, helpful syntax and function quick references can be
found in the appendices.
The following list contains other highlights of Essential MATLAB for Engineers
and Scientists, Sixth Edition:
 Warnings of the many pitfalls that await the unwary beginner
 Numerous examples taken from science and engineering (simulation, pop-
ulation modeling, numerical methods) as well as business and everyday
life
 An emphasis on programming style to produce clear, readable code
 Comprehensive chapter summaries
 Chapter exercises (answers and solutions to many of which are given in an
appendix)
 A thorough, instructive index
Essential MATLAB is meant to be used in conjunction with the MATLAB soft-
ware. The reader is expected to have the software at hand in order to work
through the exercises and thus discover how MATLAB does what it is com-
manded to do. Learning any tool is possible only through hands-on expe-
rience. This is particularly true with computing tools, which produce correct
answers only when the commands they are given and the accompanying data
input are correct and accurate.

ACKNOWLEDGMENTS
I would like to thank Mary, Clara, Zoe Rae and Zach T. for their support and
encouragement. I dedicate the sixth edition of Essential MATLAB for Engineers
and Scientists to them.
Daniel T. Valentine
1
Part 1 concerns those aspects of MATLAB that you need to know in order to
come to grips with MATLAB’s essentials and those of technical computing. Be-
cause this book is a tutorial, you are encouraged to use MATLAB extensively
while you go through the text.
PART

Essentials
This page intentionally left blank
CHAPTER 1

Introduction

THE OBJECTIVES OF THIS CHAPTER ARE: CONTENTS


 To enable you to use some simple MATLAB commands from the Using MATLAB ...... 5
Command Window. Arithmetic ................. 5
 To examine various MATLAB desktop and editing features. Variables .................... 7
 To learn some of the new features of the MATLAB R2016a Desktop. Mathematical
 To learn to write scripts in the Editor and Run them from the Editor. functions.................... 8
 To learn some of the new features associated with the tabs (in particular, Functions and
the PUBLISH and APPS features). commands ................. 8
Vectors....................... 9
Linear equations ...... 11
Tutorials and demos 12
MATLAB is a powerful technical computing system for handling scientific and The desktop ......... 13
engineering calculations. The name MATLAB stands for Matrix Laboratory, be- Using the Editor and
cause the system was designed to make matrix computations particularly easy. running a script ....... 13
A matrix is an array of numbers organized in m rows and n columns. An exam- Help, publish and
ple is the following m × n = 2 × 3 array: view ......................... 16
Symbolics and the
  MuPAD notebook
1 3 5 APP .......................... 18
A= Other APPS.............. 23
2 4 6
Additional features .. 23
Any one of the elements in a matrix can be plucked out by using the row
and column indices that identify its location. The elements in this example Sample program . 25
Cut and paste .......... 25
are plucked out as follows: A(1, 1) = 1, A(1, 2) = 3, A(1, 3) = 5, A(2, 1) = 2,
Saving a program:
A(2, 2) = 4, A(2, 3) = 6. The first index identifies the row number counted from
script files................ 27
top to bottom; the second index is the column number counted from left to Current directory ....... 28
right. This is the convention used in MATLAB to locate information in an array. Running a script from
A computer is useful because it can do numerous computations quickly, so the current folder
operating on large numerical data sets listed in tables as arrays or matrices of browser .................... 29
rows and columns is quite efficient. A program in action . 29

This book assumes that you have never used a computer before to do the sort
of scientific calculations that MATLAB handles, but are able to find your way
3
Essential MATLAB for Engineers and Scientists. DOI:10.1016/B978-0-08-100877-5.00002-5
Copyright © 2017 Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved.
Another random document with
no related content on Scribd:
Nançay is far more likely to have burned his fingers than this young
man.”
“It is strange,” remarked Jacques des Horloges; “M. de Bruneau is
the last man of whom I should expect such disloyalty; he could not
have been in his senses.”
“He says that he had been drinking when the confession was forced
from him,” Père Antoine rejoined; “it was at Archambault’s pastry
shop.”
“You have seen him, then?” asked Madame Michel eagerly.
“I went immediately to the Châtelet,” the priest replied; “I found him
much as I expected. He has not the fortitude to meet such a
calamity.”
“He has powerful patrons, mon père,” the goodwife said; “is there no
hope of intercession?”
The priest shook his head.
“None,” he answered; “there have been too many plots, too many
intrigues; they will make an example of him. The whole weight of
the Marquis de Nançay’s influence, never greater than now, will be
thrown into the scale against the prisoner.”
“Ay,” remarked Michel sternly, “’tis his opportunity to be rid of a
troublesome rival, and marvellously well planned too, if I mistake
not.”
“I fear so,” said Père Antoine thoughtfully; “it has worked out
strangely, at least. Certainly, M. de Bruneau’s death is in his favor.”
“I am sorry for the accused,” said the clockmaker; “I remember him
from a lad of twelve. ’Tis a sad end for a young man and a soldier.
Did you tell him aught of that matter whereof we spoke before?” he
added, glancing anxiously at the priest.
Père Antoine shook his head. “Nay,” he answered. “How would it
profit us? He is as good as a dead man, so could not aid us if he
would, and I have never been sure that he would. He is a feather-
brain, and we cannot put so weighty a matter into idle or desperate
hands. He cannot aid us, but he might work us some mischief with
his careless tongue even now. I deemed it best that he should die in
ignorance of that which would not serve him, and might harm
others.”
“I have felt much as you do, father,” Michel rejoined, after a
moment’s silence; “once or twice he came here to the shop, talking
with me freely, yet I did not wholly trust him. He seemed to me a
harebrained, ambitious young man, desiring nothing so much as his
own aggrandizement and not likely to welcome the thought that one
stood ahead of him upon the road to name and fortune.”
The priest did not immediately reply; he was leaning forward and
fingering out a silent piece of music on the table with his slender
fingers.
“There might have been some question as to his claim,” he said
thoughtfully; “in a case like this, where there is confiscation, he
might have had a better chance than the true heir.”
Madame Michel drew her breath deeply, clasping her hands to her
bosom.
“The finger of God is in it!” she exclaimed devoutly.
“His hand directs all things,” Père Antoine returned quietly; “it is our
blindness which does not recognize it.”
There was another pause, and in it Madame Michel surreptitiously
wiped a tear from her eyes. The regular throbbing tick of the clocks
sounded distinctly from the shop, and little Péron began to doze,
with his head on the low stool in the corner; it was past his bedtime,
but he was forgotten.
“When will M. de Bruneau be tried?” asked Jacques des Horloges, at
last.
“Immediately,” Père Antoine replied; “’tis a well established case;
there are several witnesses, all relatives of M. le Marquis.”
“Sent purposely, no doubt,” exclaimed madame indignantly. “The old
rogue!”
“I am sorry for the poor gentleman,” Michel said once more; “he is
like to have a short shrift. Will you see him again, mon père?”
“I have a permit from the king,” the priest replied, “and I shall stay
with the unhappy prisoner to the end. There is absolutely no earthly
hope, and I fear M. de Bruneau has never set great store by the
heavenly.”
As he spoke, he rose from his seat to leave them, and the
movement startled Péron, who opened his sleepy eyes just as the
priest glanced in his direction.
“The child has been asleep,” Père Antoine remarked, smiling. “How
great a blessing is the unconscious freedom from care! I had well
nigh forgotten your present, Péron,” he added, thrusting his hand
into his wallet and drawing out a pale blue silk handkerchief; “I
brought this for you, little one, because you begged for a silk
handkerchief the other day.”
The child was wide-awake now and came running to the priest, all
eagerness for the small bit of silk in Père Antoine’s outstretched
hand.
“Oh, madame, it is just like the beautiful silk in the chest in the
garret!” Péron cried, delighted; “the same pale blue—but it is not so
thick and glossy!” he added, on examination.
At the child’s words both men glanced quickly at Madame Michel,
whose face flushed scarlet.
“Hush, Péron!” she exclaimed angrily, “you do not know what you
say.”
“How is this, mother?” asked Jacques des Horloges gravely.
She laughed a little, her agitation giving way to a milder feeling.
“I left the ladder down and the little rogue is as active as a cat and
more curious,” she said, apologetically.
Père Antoine smiled, laying his hand softly on the child’s curls.
“The likeness to his father grows daily,” he remarked to Jacques; “do
you not see it?”
“I try to think it is in my eyes,” rejoined the clockmaker bluntly; “it is
like to do him more mischief than good.”
“He is in higher hands than ours,” replied the priest sadly, making a
sign as though he blessed the child, before he bade them good-night
and went on his solemn errand to the Châtelet.
CHAPTER IV
THE PASTRY SHOP ON THE RUE DES PETITS
CHAMPS

IT was one of Péron’s few privileges to pay an occasional visit to the


pastry shop of his friend Archambault. A privilege which he prized
most highly when he could go without Madame Michel, because he
was then certain to be the recipient of various little gifts of
sweetmeats, of which he did not receive so large a share in her
presence. But the permission to go alone was so rare that it was
scarcely obtained in a twelvemonth, and then only when the
goodwife was so occupied that she could not spare the time either
to make or to fetch some dainty for the dinner of Jacques des
Horloges. But it was only a few weeks after Père Antoine’s evening
visit that one of these rare opportunities presented itself, and little
Péron trotted off as fast as his sturdy legs could carry him to the Rue
des Petits Champs. He was clad in his every-day clothes, and his
taffety jacket was beginning to show threadbare spots at the
elbows; but his apparel did not disguise the child’s native grace, and
his dark eyes shone with happiness. He walked swiftly, not stopping
to speak to any one, ignoring the children at play, according to his
instructions, and clasping a livre tightly in his rosy fist; for madame
had bidden him be careful of it and bring her the change, and he
knew well that she made much ado over the careless spending of a
denier or a sou. It was a great thing for him to be trusted with so
stupendous a sum as a whole silver livre, and he felt the
responsibility, resisting the temptation to disobey orders and stop to
watch the youngsters at play in the Rue de l’Arbre Sec, which was
right in his way. With a strong appreciation of his own virtues, he
kept straight upon his course, and arrived at the pastry shop, above
the door of which swung the sign of Les Trois Champignons. In this
establishment there were two rooms,—the outer one, which Péron
entered, furnished with a long counter in front of the kitchen door,
and full of small tables for the accommodation of a motley crowd of
visitors; and the inner apartment, on the opposite side from the
kitchen, which was for the entertainment of persons of
consequence. No one was more quick to recognize the most ethereal
differences in rank or social degree than Archambault, the cook, and
like all vulgar people he was noisy in his eagerness to serve the rich
and the great; yet—with all the faults natural to his class—the
honest fellow had a good heart, and fed the poor at his back door as
liberally as he fed the rich at his front. For which he was not to
blame, as it is a common fault of human nature to prefer to receive
the poor at the back door. St. Teresa and her two sous had the help
of God, but doubtless she would have had a low seat at the pastry
cook’s.
When little Péron entered the shop, the outer room was well filled
with guests, scattered in groups at the various tables. The greater
number of them were soldiers, and there was a good deal of noisy
talk and laughter. The attendants were moving about at a rapid
pace, endeavoring to fulfil the demands made on them from every
quarter, and there was no one behind the counter when the boy
reached it. A little embarrassed by the crowd and the noise, the child
stood waiting for some one to attend to his wants, watching
meanwhile the groups nearest at hand. At a table close by sat three
young soldiers wearing the dress of musketeers. They had reached a
course of sweetmeats and pastry, which they were washing down
with a liberal supply of good red wine. A soldier is always interesting
to a boy, and little Péron gazed at these men with eager curiosity;
their rich uniforms, their fiercely curled moustaches, their polished
accoutrements, all pleased his eye. After awhile, a few words of their
conversation attracted his attention, and he listened trying to
understand, for the name of M. de Bruneau was one that he
remembered hearing from Père Antoine. The men were discussing in
low tones the trial of the latest political offender; they were talking
also of M. de Luynes and of the king, and it seemed as if the fate of
de Bruneau, for some reason, excited unusual interest. It was
evident that no one quite believed in his guilt, although no one could
prove his innocence.
“M. de Bruneau died like a gentleman at noon to-day,” remarked one
of the musketeers, eating a citron with a certain placid enjoyment of
the sweetmeat and his gruesome subject.
“I heard that his knees shook and he was sadly frightened at the
sight of the block,” said another, shrugging his shoulders.
“Parbleu! I do not blame him,” cried the third; “’tis one thing to die
in a fight, or even to fall by a sword-thrust on the Place Royale, quite
another to walk up to the block to be bled like an ox. No one seems
to know what was the full charge against him either, except the
accuser.”
“Who is a cousin of M. de Nançay, whereby hangs a tale as long as a
sermon,” said the first speaker.
“And Bruneau was the cousin of the dead marquis, was he not?”
asked the second soldier.
“Ay,” responded the other, “which is the handle of the tale.”
“And M. de Bruneau’s property is confiscated?” continued the
inquiring soldier.
“Certainly, and that is the gist of the tale!” retorted his companions,
laughing.
“His accomplices both escaped,” said the first speaker,—“one to
England, the other, M. Benoit, to Flanders.”
“M. de Bruneau stopped,” began one of the others, “to—”
“To bid his sweetheart adieu!” interjected the gayest member of the
party, laughing.
“And was taken on the Rue St. Denis by the provost-marshal and”—
the speaker held his hand over his mouth and pointed at the inner
room,—“and M. de Nançay.”
“Ventrebleu!” exclaimed the other, “what a pleasant rencounter.”
At this they all laughed loudly, and little Péron, who was still
watching and listening, wondered what could be so amusing in a
subject which seemed to be the same of which Père Antoine had
spoken so gravely. The child’s wondering gaze attracted the
attention of the youngest musketeer, and he mistook the boy’s eager
attention for a longing after the sweets on the table, seeing that he
was neglected and wore a rather shabby coat. The soldier had eaten
well and was in the humor to be not only kind but mischievous. He
leaned back in his chair and held out a rissole to Péron.
“Here, Master Bluecoat,” he said gayly, “have a tidbit. I have eaten
and you are not yet served.”
Péron shook his head, drawing back indignantly, but the musketeer
did not recognize the meaning of his repugnance.
“Come, come,” he said, “no need of shyness; I do not want it, my
boy, I have had one bite—and one of my bites is equal to three of
yours.”
He pressed it upon the child, who retreated still more toward the
counter, his little face flushing scarlet. The other two soldiers had
now become interested and each held out a sweetmeat laughing,
much diverted at the boy’s discomfiture.
“Here is a citron,” said one.
“And here a tart,” cried another, while the first offender still
flourished his rissole.
“I do not want them!” exclaimed Péron, now backed against the
counter, and looking at them in angry bewilderment.
But they were not to be put off so easily.
“You will miss it, Master Bluecoat,” said the soldier with the rissole;
“’tis an opportunity not often found at Archambault’s, sweetmeats
free of charge! Try my cake, monsieur.”
“I do not want what you have tasted!” cried Péron, with disgust.
This sally was greeted with laughter as the astonished guardsman
looked blankly at the child. He recovered, however, in an instant,
and made the boy a mocking bow.
“I beg your pardon, M. le Marquis!” he said. “Can I not order for
your excellency? Archambault does not know who is without.”
The jest caught the fancy of his idle companions.
“Give place here at the table,” they cried, clearing a space in the
dishes; “let the marquis sit!”
Before the child realized their intention, the gay musketeer had
picked him up in his arms and set him down in the center of the
table.
“Place for the pièce de résistance!” he cried, laughing; “room for M.
le Marquis de Rissole!”
Amazed, angry, half frightened, little Péron sat amid the dishes
gazing defiantly at his tormentors, too proud to cry, too surprised to
attempt an escape, remembering only to hold tightly to Madame
Michel’s precious livre. Around him the three musketeers gathered,
jesting, laughing, making him fanciful obeisances as they offered
every dish in turn, as if serving a prince. Their boisterous merriment
drew a group of idle spectators, and the child was soon the center of
a noisy circle, which constantly widened.
“M. le Marquis, permit me,” said his first tormentor, “here are some
bouchées à la reine—or here are tartelettes aux confitures.”
“And here, your excellency,” cried another, “are macarons aux
amandes!”
“Coquilles de volaille,” said a third, “œufs farcis!”
“Croquettes de ris de veau,” said one of the new-comers, “and a
roast of hobgoblins, with a sauce aux champignons!”
Amidst this hubbub the child remained silent, his courage was
wavering a little, and his small mouth closed tighter as did his
clenched fists, but he kept his dark eyes fastened defiantly on the
ring of laughing faces. The jest was no jest to him, and it required
all his force of will to bear it; but he was too proud to waver, too shy
to understand or retort to their rough pleasantry. The table on which
he sat was being crowded at the edge with dishes, and the light fell
full on his golden brown head and shabby, blue taffety jacket. The
color which had come to his face with his first anger had faded with
his increasing alarm, and his eyes looked unnaturally large and
bright.
The jesters had just begun a fresh assault with cakes and pies, when
the door of the inner room opened and a tall man came slowly out,
pausing at the sound of the merriment at the table by the counter,
and glancing in that direction with an air of displeasure. He was
evidently a person of consequence, as his bearing and the richness
of his dress indicated. His face was handsome and severe, and his
brow was concealed by a great plumed hat; he wore a collar of rich
lace over his velvet coat, and ruffles of lace, two fingers deep,
finished his satin breeches at the knee and fell over the wide tops of
his boots. He stared haughtily at the laughing circle about the boy,
and then his glance alighted on Péron and seemed for the moment
arrested by the child’s face and figure, and he looked long and
attentively at him. There were still many persons at the other tables
in the room, and presently the tall stranger began to attract nearly
as much notice, though of a respectful kind, as did Péron. But the
new-comer heeded no one save the child, and it was evident that
the scene did not meet with his approval. At last he moved forward
to the edge of the circle of jesters, and as one of the servants
approached he spoke to him with an imperative tone and gesture.
“Who is the child?” he demanded sharply.
At the sound of his voice the musketeers and their friends looked
about, and seeing him fell back discomfited; only the little boy
remained motionless in his seat on the table, not knowing how to
escape.
“Who is that child?” exclaimed the great man again, impatiently.
Some one had warned the chief pastry cook, and Archambault came
hurrying from the kitchens. A glance told him the story, and with a
swift movement he swept the little fellow from the table into the
background and stood bowing obsequiously to his tall guest.
“Are you all deaf?” exclaimed that personage tartly; “I have asked
three times about that boy. Who is he?”
“Only little Péron, M. le Marquis,” replied Archambault blandly; “the
son of a poor tradesman.”
“An ill-mannered cub to make such a scene,” remarked the great
man haughtily. “I did not know you kept a playhouse, Archambault.”
The pastry cook was profuse in his apologies. He was a little round
man with a bald spot the size of a poached egg on the back of his
round head, he had little round eyes that glistened not unkindly, and
even his fingers were as round and plump as croquettes. He made a
thousand excuses and waited on M. le Marquis to the door, looking
out at the liveried lackeys awaiting his irritable guest. When he was
safely out of hearing, however, Archambault was no longer amiable.
He hurried back, and as he passed through the group of musketeers
he flourished his hands in frantic gesticulations.
“Morbleu!” he cried, “you will ruin me, you coxcombs! That was M.
de Nançay, and he is more ticklish for the proprieties than M. de
Luynes! Between your appetites and your manners I shall be a
ruined man! If you do not mend your ways, you dogs,” he added,
shaking his fat fist at them, “I will run you all out with a spit.
Mordieu! I shall be outlawed!”
With these words he disappeared into the kitchen, pushing Péron
before him, and closing the door sharply behind him.
In spite of Péron’s recent alarm and anger, he became at once so
interested in the busy scene which opened before his eyes that he
almost forgot his troubles; but not so did Archambault. The pastry
cook seemed absorbed in thought and took no notice of the cooks
and scullions hurrying to and fro with smoking pots and gaudily
dressed dishes. He even forgot the child’s errand and hurried him
through the kitchens, across the court, and into a room which
opened at the back of the house on the Rue de Beaujolais. So rapid
had been their movements that the bewildered boy did not recollect
Madame Michel’s orders until he suddenly bethought himself of the
livre still in his hand.
“I have not the tarts,” he said, drawing back as Archambault began
to unfasten the outer door. The pastry cook stopped and rubbed his
head.
“Diable!” he ejaculated, and then after a moment’s thought he called
to a scullion.
“Gaspard, bring hither some tarts and cakes,” he said, “and be
quick!”
Péron opened his little fist at last and gravely extended the money.
“You were to take out the price,” he said.
The scullion had already hastily filled the order and put the bundle in
the small customer’s arms but without taking the livre. Archambault
meanwhile had thrust his head out from the door and looked
anxiously up and down the street; he drew back now and grasped
the child by the arm.
“Come!” he said impatiently, as Péron held back.
“I have not paid,” the boy protested, stoutly resisting.
“Some other time will do,” retorted the fat pastry cook.
“Madame Michel wished the change,” replied Péron stubbornly; “that
is why she gave me a livre.”
“Mon Dieu!” cried Archambault, beside himself with impatience,
“quick, Gaspard, the change; this child would wait for change if he
bought his own coffin!”
And it was not until this business had been transacted to Péron’s
satisfaction that he was willing to go out at the door which had been
opened for his convenience. But after the livre had been changed he
stepped out into the street, closely followed by the pastry cook.
There was no one in sight, and Archambault laid his hand on the
child’s shoulder.
“Now mind you, Péron,” he said, with emphasis, “run down to the
Rue St. Honoré and so to the shop. No time to dream now, no
dallying,—vite!” and he clapped his fat hands and laughed a little as
the boy ran off in the direction that he indicated.
He watched until the lad was out of sight and then returned to his
business with evident relief. He did not know how anxious Péron was
to be at home or what a horror he had conceived of the pastry shop.
The child ran the whole distance and arrived so out of breath that
Madame Michel marvelled and scolded while she counted the
change. She found one more pie than had been paid for, which she
however supposed to be intended as the messenger’s perquisite,
and so set her mind at rest. Her conscience permitted an increase in
the amount received more readily than a decrease in the returns
from her livre. Being satisfied with the results of Péron’s shopping,
she did not pursue her inquiries and remained ignorant of the scene
of which he had been the hero.
CHAPTER V
THE CHÂTEAU DE NANÇAY

IT was not until Péron was ten years old that he made a journey
outside the gates of Paris. Jacques des Horloges was accustomed to
go from one grand house to another, to regulate and mend the great
clocks, for his skill was held in high esteem, and such errands
frequently took him beyond the city limits. But he had never taken
the boy with him until one day, as he was setting out, Péron begged
so hard to be allowed to accompany him that he consented. The
stout Norman horse which Jacques always rode stood saddled at the
door, and the clockmaker had just finished packing his saddle-bags
when the child ran out, eager and importunate for the privilege of a
ride beyond the gates. Michel listened to the petitioner with some
amusement and a good deal of doubt. He stood hesitating, his hand
on the saddle and his eyes on the pleading face. He was wavering
between a desire to gratify the boy and a doubt of the wisdom of
yielding to persuasion; and while he was still undecided his wife
came to the door.
“Péron wants to go,” he said, smiling, “and I have the mind to take
him, only”—he paused, still looking at the child—“I am going to
Poissy and beyond.”
“To Nançay?” madame said quickly, and she too looked at Péron.
“Ah, may I not go?” cried the boy, turning from one to the other. “I
will be good, I will do just as I am bid!”
“Poor baby!” exclaimed the woman, “’tis a pity, and yet—”
“There can be no harm done, I think,” Jacques remarked, after a
moment, “and it is meet that the child should see something besides
the shop and the Rue de la Ferronnerie. Give me what he may need
for three days, and he shall go.”
Péron uttered a cry of delight, and danced about on the doorstep,
while Madame Michel hesitated yet a moment longer.
“Ought we to ask Père Antoine?” she said doubtfully.
Jacques des Horloges shook his head. “I have not time,” he said,
“and, after all, it is no great matter. So be quick, for I must be off.”
Without more ado a little bundle for Péron was added, he was
mounted behind the clockmaker, and they set out on their journey,
the child as full of eagerness as though they were going out into a
new world. He looked about him proudly from his perch behind
Jacques; he felt that it was an important event in his life, and he
was conscious of the envious glances of the children in the streets.
But the sights of the city were familiar to him, and it was not until
they had passed beyond the limits of Paris and were traversing the
green meadows that he realized the delights of a ride in the open
country. He was not a talkative child, and he took his pleasure
silently, gazing about him with great interest and noting every
unusual object. The river seemed so beautiful out here, running
through the fields, that he could scarcely believe that it was the
same Seine into which he had so often looked from the Pont Neuf.
Those observant dark eyes saw every wild flower, every green leaf
by the wayside, and followed eagerly the flight of the swallows
overhead.
Jacques des Horloges was as little inclined to conversation as the
child. The clockmaker’s broad, sturdy figure sat squarely on the back
of his stout horse, and he kept his eyes on the road, attending
steadily to his own business. He was not a romantic person, and
would have been much amazed at the child’s fancies about the
matter-of-fact objects in view. He was a plain man who saw only
plain duties in life, and, for the most part, performed his share of
them in a simple way.
This silent couple made the journey of five leagues to St. Germain-
en-Laye without interruption and without incident, and riding into
the town stopped for dinner at the Three Moons. The child, tired
from the long ride, was glad to find a seat at the table in the public
room, where they were forced to wait some time to be served, for it
was crowded with guests. It was the season for the annual fair in
the forest of St. Germain, and the inn was filled with traders,
mummers, and merrymakers going there for business or
entertainment. At a table near Michel’s sat a company of strolling
players, and the jests and the grimaces of the clown soon aroused
Péron in spite of his weariness. The grotesquely painted face and
the gay dress with its fringe of bells delighted the child and diverted
his attention even from his food. There were soldiers here too; but
he had cared less for them since the scene at Archambault’s,
although he could not yet entirely resist the fascination of their
highly polished corselets and the rattle of swords and spurs. There
were peddlers there with their packs, on the way to trade at the fair,
musicians, countrymen, a motley gathering and a lively one, the
ripple of talk and laughter, the clatter of dishes, the rush and hurry
of attendance, all enlivening the scene. Yet there was grave enough
talk whispered in some of the corners of that very room. Where
there was a knot of persons of the better class, the conversation ran
on the quarrel of the queen-mother and the king, on the defeat of
her troops at Ponts-de-Cé and the possibilities of peace; of the
influence of Albert de Luynes and the return of the Bishop of Luçon
from exile at Avignon. Food enough for talk, but it was low spoken;
there had been two courts and two factions too long for men to
venture free speech. Marie de’ Medici, the queen-mother of France,
who had ruled during the king’s long minority, could not retire from a
foremost place in the government. Jealous, spiteful, scheming,—a
wily Italian,—she never rested from her endeavors to control her son
and his affairs until she was defeated by the wit and determination
of Richelieu; and for years France beheld the strange spectacle of
two courts and two trains of courtiers, a mother and son at swords’
points with each other. Behind all this was the ever-watchful jealousy
of the two religious parties. The Huguenots, no longer protected by
the great Henry, were suspicious of his son and fearful that their
rights would be infringed. The Catholics, on the other hand,
liberated from the strong rule of the dead king, and hoping much
from Louis XIII., were as restless and eager for strife as ever, and
found themselves, in their turn, encroached upon by the Huguenots,
who were unwilling to grant the freedom of religion to others which
they demanded for themselves. So long the victims of intolerance,
they were themselves intolerant. Already the great trouble was
brewing that would culminate in the siege and fall of La Rochelle,
the stronghold of the Protestants. During the regency of Marie de’
Medici—a season of weakness between the time of Henri IV. and
that of Richelieu—the grandees had grown restless again under the
royal yoke. Since the days of François I. the power of the great
nobles had been diminishing; they saw it with infinite discontent,
and now gathered around the queen-mother, intriguing and plotting
for a larger part in affairs, encouraged to hope much from the
divisions in the state, and from the jealousy and reckless ambition of
Monsieur, the king’s brother. All these matters therefore furnished
fruitful topics of conversation at every public house; and dangerous
gossip it was.
Jacques des Horloges was too wise to join in such talk, but he met
some friends and it was some time before he set out again upon his
journey. The two—the clockmaker and the child—left the town and
rode on to Poissy, passing through the midst of the fair before they
reached the gates of that place. The booths were set up in the edge
of the forest under the shelter of the trees, and from branch to
branch were swung ropes of flowers and evergreen, from which
hung little bells that tinkled merrily with every breeze. The open
grass plots were covered with dancers, arrayed in the gayest hues,
like a moving bouquet of tulips, while the music was furnished by
various groups of players, and was full of variety, from the loud
blasts of the hautboys to the guitars which were coming into
common use, having been introduced at the French court from Italy.
There were, too, the shrill sweet notes of the flaïos de saus, or reed
flutes, which were coupled by pairs in the orchestras and played the
minor keys, some soft and even sweet, especially in the open air, in
spite of the crudeness of the instruments. The scene was not only
gay, but it had a certain rural charm of its own, which was not even
cheapened by the itinerant tradesmen who were crying their wares
by the roadside. There was a large concourse of people, for the Fête
de St. Louis never failed to bring a full attendance. There was a
poultry show, too, and a horse show, each drawing a large audience,
and a full selection of marvels to dazzle and bewilder the country
people.
Jacques des Horloges, however, was not diverted from his even
course by sights which he had witnessed every year, and he rode
along at a steady gait, until a strolling gypsy stopped his horse,
offering to tell the clockmaker’s fortune. Michel shook his head.
“Away with you,” he said impatiently, “I have more serious work to
do than to listen to your babble.”
“Have a care, master,” retorted the fortune-teller glibly; “’tis ill-luck
to scorn a friendly warning, there may be trouble ahead!”
“Pah!” ejaculated the clockmaker, urging on his stout horse, “the
devil take your nonsense.”
“’Tis not the time for indifference,” said the gypsy, holding up a long
finger; “the king makes peace with the queen; changes come;
yonder boy is not yours!”
Jacques des Horloges stirred uneasily in his saddle.
“Mère de Dieu!” he exclaimed softly, but he only urged his horse on,
without looking back until he reached the gates of Poissy.
Here they put up at the first hostelry in the main street, and Jacques
saw his horse safely stalled in the stable before he took his saddle-
bags on his arm and set out with Péron to attend to the errand
which had brought him so far. They passed through the streets out
on to the road which led along the bank of the Seine. To the left, the
ground rose gradually until it reached a hilly elevation, fringed by a
woodland. Some sheep were grazing on the slopes, and the
afternoon sun cast long shadows in the hollows. Over the tree-tops
showed the gray turrets and gabled roof of a large château. The
clockmaker plodded along, leading the child by the hand, and
neither spoke until a turn in the road brought them around the
shoulder of the hill and in full view of the house. Then Péron uttered
an exclamation of pleased surprise, and Jacques des Horloges
stopped involuntarily and stood looking at the scene.
“Do you like it?” he said, turning to the child.
“It is beautiful,” replied Péron; “is it the king’s house?”
Jacques laughed. “Nay,” he said, “did you think it like the Louvre?
We are going here to fix the old jacquemart. This is the Château de
Nançay.”
Before them the ground rose in a succession of terraces to the
elevation on which were the buildings. A stone wall ran along the
face of the lowest terrace, with great iron gates, which stood open.
Above this were three other terraces, faced by low parapets, in the
Italian fashion, and beautifully grassed and planted with roses. The
highest formed an immense quadrangle, in the center of which stood
the château and its out-buildings. It was of gray stone and of a
graceful style of architecture, a mantle of ivy climbing over its turrets
and arching the long row of windows which commanded the
terraces. Behind it were the stables and the house of the steward of
the estate. The whole place was in perfect order and beautifully
situated on the spur of the hill, overlooking the river and sheltered
by a small forest in the rear. On the central turret of the château was
one of the old jacquemarts, and even at a distance two figures could
be discerned, one on either side of the dial, which, on nearer
inspection, proved to be two knights in complete armor, who struck
the hours with their bronze maces on a great silver bell above the
face of the clock. It was a very old clock, one of the first made in
imitation of the famous jacquemart of Dijon, and this central turret
of Nançay had borne for years the name of “Tour de l’Horloge.”
To Péron, this house was more beautiful than the Louvre or the
Palais des Tournelles in the old Marais, because of the open country
about it. To the child, bred in Paris, the green field and waving trees,
the slope of the hill-tops, the blooming flower garden, was a setting
of perfect beauty. He followed the clockmaker up the successive
steps of the terraces, too obedient to lag behind, but gazing about in
pleased wonder. He saw the great velvet faces of the pansies, the
clustering roses, the more modest violets; he noticed everything that
escaped the eye of Jacques des Horloges; and he followed, in the
same silent mood, into the great house itself. They did not approach
the stately main entrance, but were admitted by a porter at a side
door. The clockmaker was expected, and being an old visitor was
permitted to set about his work undisturbed. It was his business to
wind and clean and lubricate the machinery of every clock in the
château, from the jacquemart to the cook’s timepiece, and there
were many. Jacques was a man who performed all tasks
expeditiously and quietly, and he commenced his rounds at once,
only bidding Péron keep near him. He entertained no fear of the
child getting into mischief; in that respect he was too unchildlike,
and often perplexed the good clockmaker.
There was no occasion to fear that Péron would offend for lack of
interest in what he saw; the boy was amazed and delighted at the
beauty and richness of the château’s interior. The floor of the great
hall was tessellated, paved with Italian marble, and the balustrade of
the main staircase was elaborately carved. While the clockmaker was
busily engaged with the old timepiece in the hall, Péron went about
softly, peeping in first at one door and then at another, each in turn,
giving him such a bewildering vista of beauty and luxury, that the
child fancied himself in fairyland. No one seemed to be stirring in
this part of the house; indeed the marquis was away from home,
and the little explorer, meeting no one, grew bolder and ventured
into the dining-room to look at the display of silver and gold on the
immense carved sideboard. Here were not only dishes and goblets,
but also fanciful vases and figures of the precious metals; there were
also several beautiful examples of ceramic art, the work of Maître
Bernard des Thuilleries and of his predecessor, Robbia; and the
abace and crédence, nearer the table, were covered respectively
with rare glass and plates and dishes. The room was very long, and
at the end was a mirror in a gold frame of such curious design,—
ropes of flowers tied with broad ribbons and held above and below
the glass by golden cupids,—that Péron stood a long while
examining it, not noticing his own figure reflected therein. A strange
contrast he presented to his rich surroundings, the clockmaker’s boy,
in plain, dark clothes and coarse boots, but handsome and full of
health, and large for his years.
Beyond the mirror was a door draped with pale blue hangings, and
Péron, grown bold, lifted the silken curtains and stepped into a
smaller room, softly carpeted and richly furnished. But here he was
destined to meet with a surprise. He had advanced quite a way
before he became suddenly aware that he was not alone. At the
other end of the apartment stood a child, a little girl, of about
Péron’s own age or less, and she was gazing at him in the most
profound amazement. She had seen the intruder before he was
aware of her presence, and was searching him with a glance that
was not only full of astonishment but of disdain, as she observed
every detail of his shabby appearance.
At the sight of her Péron halted too and stood returning her gaze,—
but with very different feelings. To him she seemed the most
beautiful child that he had ever seen. At the first glance he thought
her a fairy. She was small and slight, with the fair, rosy loveliness of
childhood, her great black eyes, fringed with long black lashes and
set off with delicately pencilled black brows, while, in direct contrast,
her hair was like spun gold and extremely fine and glossy. This little
vision was arrayed in pure white, with ruffles of fine lace and little
white silk shoes. It was not marvellous that the clockmaker’s child
should gaze in amazement at this small beauty who, in his eyes,
rivalled the fairest belle of the Marais.
CHAPTER VI
A BUNCH OF VIOLETS

THE two children, thus suddenly confronted, stood regarding each


other for some moments in silence. Then the little girl drew back
with a gesture which was wonderfully full of hauteur for one so
young.
“Who are you?” she demanded arrogantly. “Where did you come
from, boy?”
“From Paris,” returned Péron promptly; he was not shy of another
child.
“From Paris?” she repeated, opening her eyes to their fullest extent;
“what are you doing here, then?”
“Nothing,” the boy answered truthfully, all the while thinking more of
her wonderful appearance than of her imperious questions.
The little girl stood a moment longer as if uncertain what to do, and
then she stepped backward toward the door behind her, all the while
keeping her eyes fixed on the intruder.
“Mademoiselle!” she called loudly. “Mademoiselle Lucien!”
The portière was lifted hastily and a young woman came in answer
to the summons. The little girl pointed her finger at Péron, who still
stood there, embarrassed now by his situation but not knowing how
to escape.
“Mademoiselle, look at that boy,” cried the child, “he must be a
thief!”
“I am not!” exclaimed Péron, amazed at the accusation and
resenting it with all his honest heart.
“How did you come here, then?” asked the little girl, “and what are
you doing?”
“Go away, boy!” exclaimed Mademoiselle Lucien haughtily, catching
hold of the child by her side. “Come, Renée!” she added, “do not go
near him; there has been fever in Poissy and his clothes may be full
of it!”
“His jacket is very poor!” little Renée remarked mercilessly, “and his
shoes are coarse—are you a beggar?” she added, addressing him.
“No,” replied Péron, with passionate indignation, “I am not a beggar
or a thief, any more than you are!”
“You are an impertinent child!” said Mademoiselle Lucien, drawing
her little charge nearer to her; “if you do not go away I will call one
of the men to put you out with a whipping!”
“That you shall not!” cried Péron, his face scarlet with indignation;
“no one ever whipped me—I would kill any one who did!” and he
clenched his fists and faced them like a fury.
“Ciel!” exclaimed mademoiselle, “he is a little savage; come away,
Renée!”
But her charge was not inclined to go. She was a spoiled child and
not accustomed to obeying her governess. She found Péron more
interesting than the humble village children whom she was
accustomed to order about at her will.
“I will not go, mademoiselle,” she said wilfully; “I want to know why
he has come here in his poor jacket and his coarse boots!”
Péron was not given to conversation, but he was a child who had
listened and thought, and the shyness which had sealed his lips at
Archambault’s did not possess him to-day. He forgot it, for he was
burning with indignation at the manner in which this little demoiselle
treated him.
“You are ill-mannered to speak of my boots,” he said gravely. “Père
Antoine says that a beggar may be the same as the king, in heaven.”
Mademoiselle Lucien laughed. “What have we here?” she exclaimed;
“is this an infant preacher?”
Péron only looked at her, not understanding either her laughter or
her words. But the little girl understood the boy better than the
woman; her curiosity being excited, she was eager to pursue her
inquiries.
“Who is Père Antoine?” she demanded.
“A good man,” replied Péron promptly, “who would tell you that you
were naughty to call me a thief!”
At this juncture Jacques des Horloges appeared suddenly at the
door. He had missed the boy and was overwhelmed with amazement
to find him angrily confronting the little girl and her governess. The
latter recognized the clockmaker at once, and began to understand
the child’s appearance in the château. She listened to Michel’s
profuse apologies with contemptuous indifference.
“It does not matter as long as M. le Marquis is absent,” she said,
with a shrug; “but pray, Maître Jacques, keep the boy from running
over the house; we do not allow the village children even in the
kitchen for fear of some contagion for Mademoiselle Renée. You will
take him away from these rooms at once.”
The clockmaker obeyed without a word, but once out of hearing he
muttered loudly to himself, and to Péron’s surprise administered no
rebuke. Instead of scolding the child for his intrusion, Jacques
seemed to resent intensely Mademoiselle Lucien’s arrogant orders.
“The saucy hussy!” he ejaculated; “and in this house, too!
Mademoiselle Renée will take some infection, will she? Pah! ’tis the
boy who needs the care.”
Grumbling to himself and holding Péron tightly by the hand, the
honest man gathered up some of his tools in the hall and, still
leading the child, proceeded through a small door to the staircase
which ascended on one side of the Tour de l’Horloge. This was the
main tower of the château and was very strongly built of stone; in
the older days, before the use of artillery, it would have been
capable of a lengthy resistance. The stairs which led to the
jacquemart were constructed after the fashion of the early turret
stairs, being of stone and winding around the tower, between the
outer and inner walls, and so narrow that one resolute man could
have held the enemy at bay upon the step. They were lighted high
up by narrow, lance-shaped loopholes in the wall and were
festooned above with cobwebs; for this spot was seldom visited
except when the great clock was wound.
Jacques Michel climbed up slowly, followed by little Péron, for the
stairs were too narrow for the two to walk abreast. Half way up they
came to a door which opened into the house; here the clockmaker
paused, and laying down his tools on the step fumbled in his pockets
for a key, which he presently produced and unlocked the door. It
opened with some difficulty on its rusty hinges, and he entered the
room beyond, pushing the child before him. It was a large
apartment, evidently long unused. Three large windows looked out
over the terraces and the sloping fields beyond to the Seine. The
ceiling was of carved oak, the floor paved with enamelled tiles, the
great carved bedstead, inlaid with ivory, stood partially screened by
the Arras tapestry of the closet. The benches in the window recesses
and the arm-chairs were all beautifully carved, and in one corner of
the room was an alcove furnished with a crucifix and prie-Dieu.
Jacques des Horloges stood looking about him with an expression as
reverent as if he stood in a chapel. Péron had long ago learned the
futility of asking him questions, and he remained silent, only
observing everything with a child’s keenness of vision. The quiet and
the air of desertion about the place oppressed the boy, but he did
not speak. Finally the clockmaker seemed to recollect him and gently
pushed him toward the alcove of the crucifix.
“Go say your prayers there, Péron,” he said abruptly; “we ought to
pray here.”
“Why?” asked the child. “Is this a church? It does not look like one.”
“Nay,” replied Jacques, crossing himself, “but a good lady died here
who is now, I doubt not, an angel in Paradise.”
“Was she a saint?” inquired Péron, in an awed tone, for Père Antoine
had trained him well.
“Ay, as near one as a woman may be,” said the clockmaker bluntly.
“I know no better, nor will you ever see her equal. Say your prayer,
child, and look well at the room, for we must go on, but I would
have you see this place; and here, I think, M. de Nançay comes not
—nor the others.”
When the prayer was said, Jacques took the child to the window and
pointed out at the garden.
“You see yonder the terrace by the fountain,” he said, “I will take
you down to a door which opens from this tower, and you must go
there and wait for me. I can see you from above as I work, and will
come to you presently. It is a dizzy place up by the clock and I
would not take you.”
With this instruction, he took Péron back the way they had come,
first locking up the room and putting the key in his breast. At the
foot of the stairs they found a door which let the boy out into the
garden, and he ran off along the terrace, happy to breathe the free
air again and see the flowers; for the strange apartment and the
command to tell his beads for the sake of a dead woman had shaken
his sensitive nerves, and he was not recovered from his treatment at
the hands of little Mademoiselle de Nançay. Péron resented it with all
the strength of his proud heart, and so angry was he that the
unusual conduct of Jacques in the locked room was of less
consequence. He did not find time to wonder at it,—he could only
think of the insulting tone and words of the little girl, especially
interesting to him because she was so near his own age. He neither
understood nor appreciated class distinctions; the child Renée had
been educated in arrogance beyond her years, and recognized
differences in birth and station; Péron, on the other hand, had only
the teachings of Père Antoine, who had sought to instil into the boy’s
mind the humility of the Christian, seeing plainly enough the pride
which filled the childish heart and was likely to work mischief enough
without any prompting.
Péron walked along the terraces now to the fountain indicated by
Jacques, and here he stopped, standing with his back to the château
and looking at the flowers, the velvety grass, the birds picking on
the slopes. The splash of the fountain made pleasant music in his
ears, and he was just beginning to feel at his ease when a slight
sound above made him look up at the terrace behind. There, leaning
on the parapet and watching him curiously, was his little tormentor.
Renée was alone, having eluded the vigilance of her governess, and
her arms were resting on the stone balustrade while she leaned over
so much that her chin rested on them and her golden curls hung
over her face, shading it and framing it, while her great dark eyes
were fixed on the boy. It was a charming picture, since both children
were beautiful in their different ways and both possessed marked
characteristics. At the sight of her, Péron’s anger returned with full
force, and he turned his back on her, his fists clenched and his face
growing very red. She was not a boy, and he could not chastise her
as he had once unmercifully beaten a youngster who ventured to
stone M. de Turenne.
There is nothing more effective in reducing arrogance than silent
contempt. Péron’s manifest scorn had an immediate effect on the
little spoiled beauty of the château. She had been accustomed to
adulation, servility, humility; honest anger was new and interesting.
She was not troubled with any grown-up reserve, and there was,
too, a secret relenting. She was not an ill-natured child, only a
spoiled one, and under all lurked a tender heart. She could not
forget her unkind criticism of the stranger’s poor clothes; she had
reasoned it all out and come to a conclusion. He was the
clockmaker’s son and doubtless he was poor. Renée had a vague
idea of poverty, but she knew that it was a state which deserved
commiseration; her old nurse had taught her not to despise it, but
Mademoiselle Lucien’s subsequent teachings had not been wise; and
Renée had no mother. Her rudeness to the clockmaker’s boy
troubled her, and she was as quick to act on a good impulse as on a
bad one. Péron’s squarely turned back did not disturb her, for she
felt herself a great lady and able to bestow her favors where she
chose. Yet she was rather at loss what to say and how to begin;
above all, she saw a party of horsemen coming up the road, and
knew that her father would very soon cut short her adventure. She
received no encouragement from the boy, however, and when she
spoke at last it was in a rather uncertain voice.
“I am sorry,” she said softly.
No answer from Péron.
“I did not mean to speak of your boots,” she ventured again.
Still no reply.
“I am sorry,” said Renée once more, “and I think you are mean to be
so cross!”
Péron gave her a sidelong glance but refrained from speech, and
there was a prolonged silence. Then, just as the horsemen were
dismounting at the lowest terrace, he felt something brush his cheek
and a bunch of violets fell at his feet. He looked up then and saw
Renée running away, laughing, her golden curls waving in the breeze
and her white garments fluttering. When he was sure she could not
see him, Péron stooped down and picked up the violets; he was very
fond of flowers, and none bloomed in the Rue de la Ferronnerie. He
was still holding the nosegay when the party of cavaliers came
sauntering up the terraces, so near him that he could hear their talk.
A gay party they were, dressed in the richest fashion of the court
and led by the tall and fine figure of M. de Nançay, the same who
had seen Péron at Archambault’s. They all wore high, loose-topped
boots and full lace-ruffled breeches, with jackets of gay colors and
short cloaks of velvet thrown back on the shoulders and displaying
equally rich linings, while their hats were well trimmed with plumes.
They were lightly armed, only one or two wearing hallecrèts and
carrying pistols; they could scarcely have ridden from a greater
distance than Paris. As they approached Péron, he caught sentences
which he heard without comprehending their significance.
“’Tis dull now that the queen-mother has no court at Blois,” one of
the party remarked, “but there may yet be two at Paris. I hear, too,
that the Bishop of Luçon wants the cardinal’s hat.”
“He will not get it,” said M. de Nançay sharply. “The devil take the
Bishop of Luçon. Albert de Luynes will never see a cardinal’s hat on
the head of Jean Armand du Plessis.”
“Yet ’tis said that the queen-mother desires it,” suggested another
follower mildly, “and you, M. de Nançay, are too stanch to recede,
even after the defeat at Ponts-de-Cé.”
Nançay struck his sheathed sword across his boot.
“The queen-mother is duped,” he said; “the bishop is a fox who will
rob her sheep-fold. A fig for a woman’s wit, when she is flattered by
so skilful a priest!”
“It may be you are mistaken, M. le Marquis,” replied the first
speaker, “Madame la Mère reads well the wit of the bishop. I have
often thought that he would yet defeat M. de Luynes, and if he gets
the ear of the king—”
The marquis frowned darkly, giving the courtier a black look.
“You choose a strange subject for croaking, monsieur,” he said, in a
biting tone, “especially here!”
His companions all stared at the luckless disputant, who grew
crimson and stammered an apology which, fortunately for him, was
lost, for at that moment M. de Nançay’s eye alighted on Péron.
Jacques des Horloges had observed the party approaching, and
hurrying down from the château, with his tools, was just preparing
to leave the place with his little charge, when the marquis
discovered the boy. The sight of the child seemed to disconcert the
nobleman more than the speech of his friend, and a sharp change
came over his face. He turned to an attendant who was following at
a respectful distance.
“Who are those people—the man and the boy?” he asked sharply.
“Jacques des Horloges, the famous clockmaker of St. Honoré, M. le
Marquis,” replied the man; “the child, I think, is his—I have seen him
in his shop.”
For a moment the marquis hesitated, as if undecided whether to
recall the clockmaker or not, and his followers stood about him,
secretly amazed that he should notice such humble persons. But M.
de Nançay did not heed them, he continued to watch Michel and
Péron until both had passed out of the gates and taken the road to
Poissy. When they were out of sight he led the way to the château;
but there was a frown on his face, and his temper was more acrid
than usual on such occasions; for he had the reputation of being a
genial and hospitable host.

You might also like