0% found this document useful (0 votes)
60 views

''Intuitive understanding of Kalman filtering with MATLAB'' First Edition Adjouadi 2024 Scribd Download

Adjouadi

Uploaded by

allawyboeva
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)
60 views

''Intuitive understanding of Kalman filtering with MATLAB'' First Edition Adjouadi 2024 Scribd Download

Adjouadi

Uploaded by

allawyboeva
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/ 55

Experience Seamless Full Ebook Downloads for Every Genre at textbookfull.

com

''Intuitive understanding of Kalman filtering with


MATLAB'' First Edition Adjouadi

https://textbookfull.com/product/intuitive-understanding-of-
kalman-filtering-with-matlab-first-edition-adjouadi/

OR CLICK BUTTON

DOWNLOAD NOW

Explore and download more ebook at https://textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Kalman Filtering with Real Time Applications 5th Edition


Charles K. Chui

https://textbookfull.com/product/kalman-filtering-with-real-time-
applications-5th-edition-charles-k-chui/

textboxfull.com

Sucker Punch (Anita Blake, Vampire Hunter, #27) First


Edition Laurell K. Hamilton

https://textbookfull.com/product/sucker-punch-anita-blake-vampire-
hunter-27-first-edition-laurell-k-hamilton/

textboxfull.com

Automated Deduction CADE 27 27th International Conference


on Automated Deduction Natal Brazil August 27 30 2019
Proceedings Pascal Fontaine
https://textbookfull.com/product/automated-deduction-cade-27-27th-
international-conference-on-automated-deduction-natal-brazil-
august-27-30-2019-proceedings-pascal-fontaine/
textboxfull.com

Wall Street Journal Monday April 27 2020 News Corp

https://textbookfull.com/product/wall-street-journal-monday-
april-27-2020-news-corp/

textboxfull.com
Wall Street Journal Wednesday May 27 2020 News Corp

https://textbookfull.com/product/wall-street-journal-wednesday-
may-27-2020-news-corp/

textboxfull.com

Bishop Wonderland Badass Security Council BSC 27 L. Ann


Marie

https://textbookfull.com/product/bishop-wonderland-badass-security-
council-bsc-27-l-ann-marie/

textboxfull.com

Digital and Kalman Filtering An Introduction to Discrete


Time Filtering and Optimum Linear Estimation 2nd Edition
S. M. Bozic
https://textbookfull.com/product/digital-and-kalman-filtering-an-
introduction-to-discrete-time-filtering-and-optimum-linear-
estimation-2nd-edition-s-m-bozic/
textboxfull.com

Understanding Digital Signal Processing with MATLAB® and


Solutions. First Edition. Edition Poularikas

https://textbookfull.com/product/understanding-digital-signal-
processing-with-matlab-and-solutions-first-edition-edition-poularikas/

textboxfull.com

Innovative Technologies and Learning First International


Conference ICITL 2018 Portoroz Slovenia August 27 30 2018
Proceedings Ting-Ting Wu
https://textbookfull.com/product/innovative-technologies-and-learning-
first-international-conference-icitl-2018-portoroz-slovenia-
august-27-30-2018-proceedings-ting-ting-wu/
textboxfull.com
Intuitive Understanding
of Kalman Filtering
with MATLAB®
Intuitive Understanding
of Kalman Filtering with
MATLAB®

Armando Barreto
Malek Adjouadi
Francisco R. Ortega
Nonnarit O-larnnithipong
MATLAB® is a trademark of Te MathWorks, Inc. and is used with permission. Te MathWorks does not warrant
the accuracy of the text or exercises in this book. Tis book’s use or discussion of MATLAB® sofware or related
products does not constitute endorsement or sponsorship by Te MathWorks of a particular pedagogical approach
or particular use of the MATLAB® sofware.

First edition published 2021


by CRC Press
6000 Broken Sound Parkway NW, Suite 300, Boca Raton, FL 33487–2742
and by CRC Press
2 Park Square, Milton Park, Abingdon, Oxon, OX14 4RN
© 2021 Taylor & Francis Group, LLC
CRC Press is an imprint of Taylor & Francis Group, LLC
Reasonable eforts have been made to publish reliable data and information, but the author
and publisher cannot assume responsibility for the validity of all materials or the consequences
of their use. Te authors and publishers have attempted to trace the copyright holders of all
material reproduced in this publication and apologize to copyright holders if permission
to publish in this form has not been obtained. If any copyright material has not been
acknowledged please write and let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted,
reproduced, transmitted, or utilized in any form by any electronic, mechanical, or other means,
now known or hereafer invented, including photocopying, microflming, and recording, or in
any information storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.
copyright.com or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive,
Danvers, MA 01923, 978–750–8400. For works that are not available on CCC please contact
mpkbookspermissions@tandf.co.uk
Trademark notice: Product or corporate names may be trademarks or registered trademarks,
and are used only for identifcation and explanation without intent to infringe.
Library of Congress Cataloging‑in‑Publication Data
A catalog record for this book has been requested
ISBN: 978-0-367-19135-1 (hbk)
ISBN: 978-0-367-19133-7 (pbk)
ISBN: 978-0-429-20065-6 (ebk)
Typeset in Minion Pro
by Apex CoVantage, LLC
Contents

Acknowledgments, xi
Authors, xiii
Introduction, xv

PART I Background

CHAPTER 1 ■ System Models and Random Variables 3


1.1 DETERMINISTIC AND RANDOM MODELS
AND VARIABLES 3
1.2 HISTOGRAMS AND PROBABILITY FUNCTIONS 6
1.3 THE GAUSSIAN (NORMAL) DISTRIBUTION 12
1.4 MODIFICATION OF A SIGNAL WITH GAUSSIAN
DISTRIBUTION THROUGH A FUNCTION
REPRESENTED BY A STRAIGHT LINE 14
1.5 EFFECTS OF MULTIPLYING TWO GAUSSIAN
DISTRIBUTIONS 21
CHAPTER 2 ■ Multiple Random Sequences
Considered Jointly 25
2.1 JOINT DISTRIBUTIONS—BIVARIATE CASE 25
2.2 BIVARIATE GAUSSIAN DISTRIBUTION—
COVARIANCE AND CORRELATION 32
2.3 COVARIANCE MATRIX 38
2.4 PROCESSING A MULTIDIMENSIONAL GAUSSIAN
DISTRIBUTION THROUGH A LINEAR
TRANSFORMATION 39

v
vi ■ Contents

2.5 MULTIPLYING TWO MULTIVARIATE


GAUSSIAN DISTRIBUTIONS 40
CHAPTER 3 ■ Conditional Probability, Bayes’ Rule
and Bayesian Estimation 45
3.1 CONDITIONAL PROBABILITY AND THE
BAYES’ RULE 45
3.2 BAYES’ RULE FOR DISTRIBUTIONS 50

PART II Where Does Kalman Filtering Apply and


What Does It Intend to Do?
CHAPTER 4 ■ A Simple Scenario Where Kalman
Filtering May Be Applied 55
4.1 A SIMPLE MODELING SCENARIO: DC MOTOR
CONNECTED TO A CAR BATTERY 55
4.2 POSSIBILITY TO ESTIMATE THE STATE VARIABLE
BY PREDICTION FROM THE MODEL 57
4.2.1 Internal Model Uncertainty 58
4.2.2 External Uncertainty Impacting the System 58
4.3 POSSIBILITY TO ESTIMATE THE STATE VARIABLE BY
MEASUREMENT OF EXPERIMENTAL VARIABLES 59
4.3.1 Uncertainty in the Values Read of the Measured
Variable 59
CHAPTER 5 ■ General Scenario Addressed by Kalman
Filtering and Specifc Cases 61
5.1 ANALYTICAL REPRESENTATION OF A GENERIC
KALMAN FILTERING SITUATION 62
5.2 UNIVARIATE ELECTRICAL CIRCUIT EXAMPLE
IN THE GENERIC FRAMEWORK 67
5.3 AN INTUITIVE, MULTIVARIATE SCENARIO WITH
ACTUAL DYNAMICS: THE FALLING WAD OF PAPER 70
CHAPTER 6 ■ Arriving at the Kalman Filter Algorithm 75
6.1 GOALS AND ENVIRONMENT FOR EACH
ITERATION OF THE KALMAN FILTERING
ALGORITHM 75
Contents ■ vii

6.2 THE PREDICTION PHASE 76


6.3 MEASUREMENTS PROVIDE A SECOND SOURCE
OF KNOWLEDGE FOR STATE ESTIMATION 78
6.4 ENRICHING THE ESTIMATE THROUGH BAYESIAN
ESTIMATION IN THE “CORRECTION PHASE” 79
CHAPTER 7 ■ Refecting on the Meaning and Evolution of
the Entities in the Kalman Filter Algorithm 87
7.1 SO, WHAT IS THE KALMAN FILTER EXPECTED
TO ACHIEVE? 87
7.2 EACH ITERATION OF THE KALMAN FILTER
SPANS “TWO TIMES” AND “TWO SPACES” 88
7.3 YET, IN PRACTICE ALL THE COMPUTATIONS
ARE PERFORMED IN A SINGLE, “CURRENT”
ITERATION—CLARIFICATION 90
7.4 MODEL OR MEASUREMENT? KG DECIDES
WHO WE SHOULD TRUST 91

PART III Examples in MATLAB®

CHAPTER 8 ■ MATLAB® Function to Implement and


Exemplify the Kalman Filter 103
8.1 DATA AND COMPUTATIONS NEEDED FOR
THE IMPLEMENTATION OF ONE ITERATION
OF THE KALMAN FILTER 103
8.2 A BLOCK DIAGRAM AND A MATLAB®
FUNCTION
FOR IMPLEMENTATION OF ONE KALMAN FILTER
ITERATION 106
8.3 RECURSIVE EXECUTION OF THE KALMAN FILTER
ALGORITHM 108
8.4 THE KALMAN FILTER ESTIMATOR AS A “FILTER” 110
CHAPTER 9 ■ Univariate Example of Kalman Filter
in MATLAB® 113
9.1 IDENTIFICATION OF THE KALMAN FILTER
VARIABLES AND PARAMETERS 113
9.2 STRUCTURE OF OUR MATLAB® SIMULATIONS 114
viii ■ Contents

9.3 CREATION OF SIMULATED SIGNALS:


CORRESPONDENCE OF PARAMETERS AND
SIGNAL CHARACTERISTICS 116
9.4 THE TIMING LOOP 119
9.5 EXECUTING THE SIMULATION AND
INTERPRETATION OF THE RESULTS 121
9.6 ISOLATING THE PERFORMANCE OF THE MODEL
(BY NULLIFYING THE KALMAN GAIN) 125
CHAPTER 10 ■ Multivariate Example of Kalman Filter
in MATLAB® 131
10.1 OVERVIEW OF THE SCENARIO AND SETUP
OF THE KALMAN FILTER 131
10.2 STRUCTURE OF THE MATLAB® SIMULATION
FOR THIS CASE 134
10.3 TESTING THE SIMULATION 140
10.4 FURTHER ANALYSIS OF THE SIMULATION RESULTS 144
10.5 ISOLATING THE EFFECT OF THE MODEL 148

PART IV Kalman Filtering Application to IMUs

CHAPTER 11 ■ Kalman Filtering Applied to 2-Axis Attitude


Estimation from Real IMU Signals 153
11.1 ADAPTING THE KALMAN FILTER FRAMEWORK
TO ATTITUDE ESTIMATION FROM IMU SIGNALS 154
11.2 REVIEW OF ESSENTIAL ATTITUDE CONCEPTS:
FRAMES OF REFERENCE, EULER ANGLES AND
QUATERNIONS 154
11.3 CAN THE SIGNALS FROM A GYROSCOPE BE
USED TO INDICATE THE CURRENT ATTITUDE
OF THE IMU? 159
11.4 CAN WE OBTAIN “MEASUREMENTS” OF
ATTITUDE WITH THE ACCELEROMETERS? 160
11.5 SUMMARY OF THE KALMAN FILTER
IMPLEMENTATION FOR ATTITUDE
ESTIMATION WITH AN IMU 165
Contents ■ ix

11.6 STRUCTURE OF THE MATLAB® IMPLEMENTATION


OF THIS KALMAN FILTER APPLICATION 166
11.7 TESTING THE IMPLEMENTATION OF KALMAN
FILTER FROM PRE-RECORDED IMU SIGNALS 170
CHAPTER 12 ■ Real-Time Kalman Filtering Application
to Attitude Estimation from IMU Signals 179
12.1 PLATFORM AND ORGANIZATION OF THE
REAL-TIME KALMAN FILTER IMPLEMENTATION
FOR ATTITUDE ESTIMATION 180
12.2 SCOPE OF THE IMPLEMENTATION AND
ASSUMPTIONS 181
12.3 INITIALIZATION AND ASSIGNMENT OF
PARAMETERS FOR THE EXECUTION 184
12.4 BUILDING (COMPILING AND LINKING) THE
EXECUTABLE PROGRAM RTATT2IMU.EXE—
REQUIRED FILES 185
12.5 COMMENTS ON THE CUSTOM MATRIX AND
VECTOR MANIPULATION FUNCTIONS 186
12.6 INPUTS AND OUTPUTS OF THE REAL-TIME
IMPLEMENTATION 189
12.7 TRYING THE REAL-TIME IMPLEMENTATION OF
THE KALMAN FILTER FOR ATTITUDE ESTIMATION 191
12.8 VISUALIZING THE RESULTS OF THE REAL-TIME
PROGRAM 192

APPENDIX A LISTINGS OF THE FILES FOR REAL-TIME


IMPLEMENTATION OF THE KALMAN
FILTER FOR ATTITUDE ESTIMATION WITH
ROTATIONS IN 2 AXES, 197

REFERENCES, 217

INDEX, 221
Acknowledgments

T he interest in the Kalman Filter that triggered the review of various


sources describing it; the refections about its components; its simula-
tion and real-time implementation was prompted by the participation of
the authors in research projects where this kind of estimator can be used
advantageously. In particular, the authors wish to acknowledge the sup-
port from grants CNS-1532061, IIS-1948254, CNS-1551221, CNS-1338922,
BCS-1928502 and CNS-1920182, from the National Science Foundation.

xi
Authors

Armando Barreto, PhD, is Professor of the Electrical and Computer Engi-


neering Department at Florida International University, Miami, as well as
the Director of FIU’s Digital Signal Processing Laboratory, with more than
25 years of experience teaching DSP to undergraduate and graduate stu-
dents. He earned his PhD in electrical engineering from the University of
Florida, Gainesville. His work has focused on applying DSP techniques to
the facilitation of human–computer interactions, particularly for the ben-
eft of individuals with disabilities. He has developed human–computer
interfaces based on the processing of signals and has developed a system
that adds spatialized sounds to the icons in a computer interface to facili-
tate access by individuals with “low vision.” With his research team, he has
explored the use of Magnetic, Angular-Rate and Gravity (MARG) sensor
modules and Inertial Measurement Units (IMUs) for human-computer
interaction applications. He is a senior member of the Institute of Electri-
cal and Electronics Engineers (IEEE) and the Association for Computing
Machinery (ACM).

Malek Adjouadi, PhD, is Ware Professor with the Department of Electri-


cal and Computer Engineering at Florida International University, Miami.
He received his PhD from the Electrical Engineering Department at the
University of Florida, Gainesville. He is the Founding Director of the Cen-
ter for Advanced Technology and Education funded by the National Sci-
ence Foundation. His earlier work on computer vision to help persons with
blindness led to his testimony to the U.S. Senate on the committee of Vet-
erans Afairs on the subject of technology to help persons with disabilities.
His research interests are in imaging, signal processing and machine learn-
ing, with applications in brain research and assistive technology.

xiii
xiv ■ Authors

Francisco R. Ortega, PhD, is an Assistant Professor at Colorado State


University and Director of the Natural User Interaction Lab (NUILAB).
Dr. Ortega earned his PhD in Computer Science (CS) in the feld of
Human-Computer Interaction (HCI) and 3D User Interfaces (3DUI) from
Florida International University (FIU). He also held a position of Post-Doc
and Visiting Assistant Professor at FIU. His main research area focuses on
improving user interaction in 3DUI by (a) eliciting (hand and full-body)
gesture and multimodal interactions, (b) developing techniques for multi-
modal interaction, and (c) developing interactive multimodal recognition
systems. His secondary research aims to discover how to increase interest
for CS in non-CS entry-level college students via virtual and augmented
reality games. His research has resulted in multiple peer-reviewed publi-
cations in venues such as ACM ISS, ACM SUI, and IEEE 3DUI, among
others. He is the frst-author of Interaction Design for 3D User Interfaces:
Te World of Modern Input Devices for Research, Applications and Game
Development (CRC Press, 2020).

Nonnarit O-larnnithipong, PhD, is an Instructor at Florida International


University. Dr. O-larnnithipong earned his PhD in Electrical Engineer-
ing, majoring in Digital Signal Processing from Florida International Uni-
versity (FIU). He also held a position of Post-Doctoral Associate at FIU
between January and April 2019. His research has focused on (1) imple-
menting the sensor fusion algorithm to improve orientation measurement
using MEMS inertial and magnetic sensors and (2) developing a 3D hand
motion tracking system using IMUs and infrared cameras. His research
has resulted in multiple peer-reviewed publications in venues such as HCI‑
International and IEEE Sensors.
Introduction

T he Kalman Filter, envisioned by Dr. Rudolf E. Kalman (1930–2016)


provides an efective mechanism to estimate the state of a dynamic sys-
tem when a model is available to sequentially predict the state and sequen-
tial measurements are also available. Tis is a common kind of situation in
the study of many practical dynamical systems, in diverse felds.
Te Kalman Filter has had an important impact on advances within
the felds related to the navigation of ships, aircraf and spacecraf. In
those initial areas of use, the Kalman Filter was almost exclusively used
for highly specifc applications, by a very small group of highly special-
ized users. However, in the XXI century its potential application to small
robots and miniature unmanned vehicles has broadened the appeal of this
powerful estimation approach to a much wider audience. Furthermore,
the recent emergence of cheap, miniaturized Inertial Measurement Units
(IMUs) or Magnetic, Angular Rate and Gravity (MARG) sensing modules
in contemporary applications has magnifed the importance of techniques
such as Kalman Filtering, capable of combining information from mul-
tiple sensors. Of course, all of these contemporary applications work on
digitized data, and, as such, are addressed by the Discrete Kalman Filter,
which is the subject of this book.
Tis book is our efort to provide that wider audience with a presenta-
tion of the Kalman Filter that is not a mere “cookbook” list of steps (which
may result in a sub-optimal use of this important tool), while not requir-
ing the reader to wade through several formal proofs to accomplish a strict
derivation of the algorithm. Tose proofs were given by Kalman in his
1960 paper and others who have studied the issue from a formal perspec-
tive since then.
Instead, it is our hope to provide the reader with an explanation of the
Kalman Filter approach that requires a minimum of background concepts,
presented simply and succinctly in Part I of this book. We expect that this

xv
xvi ■ Introduction

concise background review will, nonetheless, be enough to help the reader


see why it is that the Kalman Filter is capable of obtaining improved esti-
mates of the variables studied. Most importantly, we would like to help the
reader acquire an intuitive understanding of the meaning of all the param-
eters involved in the Kalman Filter algorithm and their interactions. Te
development of that intuitive understanding of the elements at play in the
Kalman Filter, and how they come together, according to the background
concepts, is the objective of Part II of this book. Te chapters in Part II
lead the reader to the formulation of the Kalman Filter algorithm as the
logical conclusion of the considerations made throughout that part of
this book. Part III of this book focuses on of-line implementation of the
Kalman Filter to address estimation challenges of increasing complexity.
Tis third part starts by leveraging the understanding of the Kalman Filter
algorithm to develop a MATLAB implementation for a single Kalman
Filter iteration. Te rest of the of-line examples in this book are developed
from that basic one-iteration function, which can be tailored to create of-
line Kalman Filter solutions to diverse estimation problems. Part IV of
this book includes two chapters that focus on the application of Kalman
Filtering to the estimation of orientation of a miniature IMU module, uti-
lizing the gyroscope and accelerometer signals provided by the module.
Te frst of the two chapters of this part develops an of-line solution that
still uses the basic one-iteration MATLAB function created at the begin-
ning of Part III. Te gyroscope and accelerometer signals are read from a
pre-recorded fle which was written while the IMU module was subjected
to a specifc series of orientation changes, so that the results can be com-
pared with the known series of orientations experienced by the module.
Te second chapter in Part IV of this book reproduces the implementation
of the algorithm in a C program which calculates the Kalman Filter results
in real time and stores them to a text fle, for later review.
Our emphasis in writing this book has been to foster in the reader an
intuitive understanding of the Kalman Filtering process. To that end,
we have tried to use analogies and pictorial representations to inform
the reader of the main concepts that need to be understood in order to
“make sense” of the elements in the Kalman Filter algorithm, their prac-
tical meaning, their relationships and the impact that each one of them
has in the fulfllment of the goals of the Kalman Filter. Also to that end,
we have included a number of “MATLAB code” segments, which are
sometimes scripts (i.e., plain sequences of MATLAB commands) and
some other times custom MATLAB functions. In either case, the reader
Introduction ■ xvii

is encouraged to execute the MATLAB code as originally presented, to


observe the results in MATLAB, and then explore the concepts by modify‑
ing the parameters involved in the code, observing the resulting changes in
the outcomes. Tis type of exploration of the concepts may be powerful in
helping to develop the intuition we want the reader to achieve.
While we, and everyone else, refers to the algorithm that is the sub-
ject of this book as a “flter,” we would like to warn the reader that the
algorithm is really a “state estimator,” which, depending on the context,
may have multiple signals “coming in” as “inputs” (which we will mainly
identify with the “measurements”) and yield values of multiple “state
variables” afer each iteration. Terefore, the Kalman Filter is not con-
strained to the most familiar framework in which one “input signal” is
fed into a “flter” to obtain from it a “cleaner output signal.” Nonetheless,
some specifc confgurations of the Kalman Filter estimator may actually
involve two signals for which the “cleaning” efect of an input may be
apparent in an output signal. We will show a couple of such instances in
the examples.
Finally, a few important notes:

• Tis book focuses on the Discrete Kalman Filter. Terefore, with the
exception of the initial discussion in Section 1.1, we will be dealing
with discrete‑time sequences. However, to keep compatibility with the
notation used in many sources related to Kalman Filtering (including
Kalman’s 1960 paper) we will denote those sequences as, for example,
x(t). In other words, we will use “t” as a discrete‑time index. (Tis is in
contrast to many signal processing books which use “t” for continu-
ous time and another variable, e.g., “n” to index discrete time.)
• Our discussions will involve scalar variables and matrices (or vec-
tors, as sub-cases of matrices). To diferentiate them we will use bold
typeface for matrices and vectors. For example, v1(t) represents a sca‑
lar sequence of (digitized) voltages, while F(t) is the state transition
matrix, which may vary from sampling instant to sampling instant, as
it is shown as a function of “t.”
• In addition to having included the listings of all the “MATLAB codes”
in the chapter where each is frst mentioned, all these fles can be
retrieved from the repository at https://github.com/NuiLab/IUKF.
• Due to the font and margins used, in some instances, a long line of
MATLAB code may be printed in this book partially “wrapped” into
the next line. Te fles in the repository do not have this efect.
xviii ■ Introduction

• In the “MATLAB codes” provided we have used a limited palette


of colors for the figures, so that it might still be possible to distin-
guish several traces in the figures printed using grayscale levels for
the physical edition of this book. The readers are invited to change
the color assignments to take full advantage of the color capabilities
of the computer monitors they will be using when executing the
functions in MATLAB.
MATLAB is a registered trademark of
The MathWorks, Inc. For product information,
please contact:
The MathWorks, Inc.
3 Apple Hill Drive
Natick, MA 01760-2098 USA
Tel: 508 647 7000
Fax: 508-647-7001
E-mail: info@mathworks.com
Web: www.mathworks.com
I
Background

T he objective of the three chapters in this part of the book is to pro-


vide the reader with the background concepts that will be essential to
understand the elements involved in the kind of estimation challenge that
the Kalman Filter addresses. Tis background is also necessary to follow
the reasoning steps that will lead us to the Kalman Filter algorithm, in
Part II.
We expect that the reader of this book will be primarily interested in
understanding and applying the Kalman Filter. As such, we have tried to
keep the background chapters in this part of the book very concise and “to
the point.” Clearly, any of the concepts outlined in these chapters could
be developed much more extensively, and put into a wider, more formal
context. Instead we have tried to communicate only the concepts that will
be used in our future reasoning (Part II) and we have emphasized descrip-
tions of these concepts in familiar terms, whenever possible.
We strongly suggest that the reader reviews these short background
chapters. We hope these chapters will “fll any gaps” in the knowledge
of some of our readers, so that they will be well equipped to follow and
assimilate our reasoning through Part II. Even if you believe you are fairly
familiar with all these background items, it will likely be worthwhile
reviewing these chapters to make sure you identify our specifc view of
these concepts, which should facilitate your reading of Part II.

1
CHAPTER 1

System Models and


Random Variables

Tis chapter presents the reader with the concept of a model for a system
and justifes the need to address some variables as random (and not deter-
ministic) variables. Te remainder of this chapter is devoted to provid-
ing an intuitive understanding of the typical mechanisms that are used
to characterize random variables, emphasizing the understanding of how
the characterization applies to the digitized values of a signal. Te latter
portion of this chapter focuses on the Gaussian (Normal) probability dis-
tribution, its notation, the efect of processing samples that have a Gaussian
distribution through a transformation represented by a straight line, and
the characteristics exhibited by a random variable that is the result of mul-
tiplying two variables that have Gaussian probability distributions.

1.1 DETERMINISTIC AND RANDOM


MODELS AND VARIABLES
Engineers very ofen aim at providing real-life solutions to real-life problems.
However, engineers very seldom attack the problem directly on the physical
reality or circumstance where the “problem” lies. Instead, engineers abstract
the critical functional aspects of a real-life problem in an operational model.
Te model frequently is an intangible representation of the real situation that
can, nonetheless, be manipulated to predict what would be the outcomes of
diferent changes in the inputs or the structure of the real-life situation.
Engineers use knowledge of the physical world to emulate real-life
constraints in the manipulations of their abstract models, so that results
3
4 ■ Kalman Filtering with MATLAB®

obtained from the models are good predictors of what will happen if the
same manipulations applied to the model are implemented in the real
world. Tose real-life constraints and the manipulations performed in
the model are commonly expressed and achieved in mathematical terms.
For example, Kirchhof’s Voltage Law states that the net sum of voltages
around a loop is zero (Rizzoni 2004):

∑V = 0
i
i (1.1)

Using this and the model of the relationship between the current iR through
a resistor R and the voltage VR across its terminals (“Ohm’s Law”):

VR = R I R (1.2)

one can calculate, using only algebra, the voltages at the nodes of a resistive
circuit with one loop.
For example, if we “simulate” a sinusoidal voltage source, Vs(t) = sin(ωt),
applied to the circuit in Figure 1.1, we can use the model to develop an “equa-
tion” that would predict the value of the output voltage Vo(t) for any time t:

Vs (t ) −VR1 (t ) −VR2 (t ) = 0 (1.3)

Vs (t ) −(R1 * I R1 (t )) −(R2 * I R2 (t )) = 0 (1.4)

I R1 (t ) = I R2 (t ) = I (t ) (1.5)

Vs (t ) = (R1+ R2) * I (t ) (1.6)

Vs (t )
I (t ) = (1.7)
R1+ R2

FIGURE 1.1 Simple electrical circuit with just one loop.


System Models and Random Variables ■ 5

And

Vo (t ) = VR2 (t ) = R2 * I (t ) (1.8)

So
R2
Vo (t ) = Vs (t ) (1.9)
R1+ R2
Tat is:

sin (˜t ) * R2
Vo (t ) = (1.10)
(R1+ R2)
If we attach to this model “nominal” values of the elements (R1, R2, ω) that
replicate the real behavior of the physical components in a real-life circuit,
we could “predict” the value of Vo(t) at any desired time t. For example, if
R1 = 10,000 Ohm, R2 = 10,000 Ohm and ω = 3.1416 radians per second,
then our model predicts:

sin (3.1416t ) * 10000


Vo (t ) = (1.11)
(10000 +10000)
Or

Vo (t ) = 0.5 sin (3.1416 * t ) Volts (1.12)

From this we could predict that at t = 0.5 seconds, Vo = 0.5 volts. If t = 1.0
seconds, Vo = 0 V. If t = 1.5 seconds, Vo = –0.5 V, etc.
Equation 1.12 is the analytic expression of a deterministic model for
Vo(t). You plug in the value of t and the model tells you what the specifc
value of Vo will be (as estimated by this model). And you get a specifc
answer for each and any value of t you may want to ask about.
It is important to highlight three aspects of these deterministic models:

1. Tey will yield a specifc value of the output variable for any value of
the input variable, “no exceptions,” which sounds great, and makes
engineers very enthusiastic about them.
2. But, getting “an answer” from these models does not imply in any
way that you are getting “the real answer.” Tat is, if the model is not
6 ■ Kalman Filtering with MATLAB®

appropriately matched to the real-life situation, the value of the estima-


tion provided by the model could be completely wrong. (I.e., it could be
very diferent from what happened in the physical system being studied.)
As a simple example, consider how wrong the estimates obtained from
Equation 1.12 would be if it was used to predict the output voltage of a
circuit exactly as described earlier, but with a resistor R2 = 1000 Ohms!
3. Te deterministic characterization of the signal Vo(t) allows us to
fully describe it to another person. I could send an email to a col-
league in Germany including Equation 1.12 and she could use it to
obtain the same plot of Vo(t) that I can get where I am.

However, we are unable to predict the values of many real-life signals in the
defnitive way provided by a deterministic characterization, such as Equa-
tion 1.12. For example, there is no deterministic model that will accurately
tell me the value of voltage coming from a microphone, Vo(t), when I clap
my hands next to it.
We know the microphone will yield a voltage that varies through time,
alternating above and below 0 V, but there is no equation that can tell
me the specifc value of voltage that an oscilloscope will show right at
t = 0.020 seconds (20 milliseconds), from the moment when my two hands
frst touch each other when I clap. Tis is an example of a signal that can-
not be easily characterized with a deterministic model. In this example,
Vo(t) is best characterized as a “random variable.”
Tis seems to be a considerable setback. How can I characterize a ran-
dom variable like the voltage signal generated when I clap? Is there any-
thing I can say about it to describe it? Or, in other words, how can I try to
describe a random variable? If we were to look at the voltage coming out
of a (“dynamic”) microphone when I clap, we would notice that there are
“certain things” that can be said about it. If we are looking at the voltage
straight from the microphone, we will see that it is very unlikely to ever
reach outside a (symmetric) range of voltages. For example, it is not likely
to be above 1 Volt or below -1 Volt. In fact, it seems that “most of the time”
the voltage level is closely above or below 0 Volts.

1.2 HISTOGRAMS AND PROBABILITY FUNCTIONS


Furthermore, there is a “standard way” in which we can summarize these
observations about which values are taken by the random signal (particu-
larly well suited for a digitized signal). We can develop the histogram of
the digitized signal (O’Connell, Orris, and Bowerman 2011; Field 2013).
System Models and Random Variables ■ 7

A histogram for a digitized signal is built simply by dividing a range of


amplitudes of the signal in adjacent “bins” of a certain width (for example,
one bin from 0.00 to 0.05 and then another bin from 0.05 to 0.10, etc.), and
then “placing” each value of the random time series representing the digitized
signal in its corresponding bin, according to its amplitude. Afer doing this
for the whole time series, the plot of all the bins, each represented by a rect-
angle whose height is the number of signal samples ultimately contained in
that bin, is the histogram of that signal. Whoever develops the histogram
needs to decide frst on the location of the bin boundaries. Usually, the width
of all the bins is the same. Figure 1.2 shows the creation of a histogram for a
random discrete-time signal. (Te signal is assumed to have many more than
the fve samples shown in the fgure to illustrate the process.)

Important Note: Please be aware that, from this point forward, we will use
“t” as a discrete-time index (McClellan, Schafer, and Yoder 2003, 2016).
Tat is, we will use “t” when referring to discrete samples of a digitized
signal, such as x(t). We have chosen to use “t” to represent discrete time to
keep compatibility with other texts discussing Kalman Filtering, including
Kalman’s paper (Kalman 1960).

Te histogram is one “practical” tool that we have for the characterization of


a random signal. We may not be able to “fully” (“deterministically”) forecast
the value of the signal at any arbitrary time, but we can at least convey to
others which amplitude values the random signal takes on more frequently.
In fact, if we normalize the height of each bar in a histogram, dividing it by
the total number of signal samples that was used to create it, the resulting
graph gives us an empirical sense of “how likely it is that the random signal
used to build the histogram will take a value within the range represented
by a given bar.” For example, if we use 1000 samples of a random signal to
develop a histogram and 126 are placed in the histogram bin from 2.0 to 2.1,
this will be telling us that 126 / 1000 = 0.126 or 12.6% of this segment of the
random variable samples had an amplitude between 2.0 and 2.1. Now, if we
were to take another 1000 points of the same random variable and develop
the same kind of histogram we could provide an educated guess in answer-
ing the question: What is the probability that in this new segment a sample
will land in the bin from 2.0 to 2.1? We could answer 12.6% (or 0.126).
In other words, the normalized histogram provides us with an empirical
(coarse) way to determine the probability that a certain random variable
(e.g., the amplitude of the random signal) will land in a given interval.
8 ■
Kalman Filtering with MATLAB®

FIGURE 1.2 Creation of the histogram of a random discrete time signal. (Only fve samples are shown, as examples.)
System Models and Random Variables ■ 9

As an example, consider the creation of the following random discrete


signal in MATLAB and the development of its normalized histogram
(also in MATLAB). Please note that the MATLAB command “rng(12345,
‘v5normal’)” resets the random number generator in MATLAB, load-
ing the seed value 12345. Tis will make it possible to obtain repeatable
(pseudo) random sequences every time this script is executed. If that is not
desired, the line with the rng command can simply be “commented out,”
by typing a “%” character at the beginning of that line.

%%% MATLAB CODE 01.01 ++++++++++++++++++++++++++++++++


rng(12345,’v5normal’); % Resets the Random Number
% Generator to ver5. Normal, seed = 12345;
N = 10000; % Total number of signal samples
x = randn(N,1);
% NOTE: M’ yields the conjugate transpose of matrix M.
% If M is real, M’ just transposes it
n = linspace(0,(N-1),N)’;
figure; plot(n,x,’k’); grid;
xlabel(‘ Discrete time index t’);
ylabel(‘x(t)’);

% For the Normalized Histogram


% [N x binwidth]/NormFactor = total_area/F = 1.0
% -> NormFactor = N x binwidth
binwidth = 0.1;
EDGES = [-3.0:binwidth:3];
NormFactor = N * binwidth;
figure; bar(EDGES,((histc(x,EDGES))/
NormFactor),0.95,’k’);grid;
xlabel(‘x’);
ylabel(‘Normalized histogram of x’);
%%% MATLAB CODE 01.01 ++++++++++++++++++++++++++++++++

Te normalized histogram shown in Figure 1.4 conveys some interest-


ing information. It tells us that the values of the random digitized signal,
or “time series” shown in Figure 1.3, occur with almost equal frequency
above and below zero. It also tells us that very few, if any, samples had a
value of more than 3 or less than -3. Further, there is a distinct pattern
in which the “probability” that a sample value is contained in a given bin
decreases from the bins closest to 0 to those close to 3 or -3. It is also
clear that the bin that captured the largest number of samples (i.e., the
10 ■ Kalman Filtering with MATLAB®

FIGURE 1.3 10,000 points of a random time series with mean 0 and variance 1.0.

FIGURE 1.4 Normalized histogram of 10,000 points of a random time series


with mean 0 and variance 1.0.
Another Random Scribd Document
with Unrelated Content
into the Government as a counter-balancing influence, can be read
in the biographies of all these men, and of many less famous.
London echoed with the Marquess’s deep disgust; every man of fair
parts in England sympathized with it, unless his personal interests or
feelings bound him to blind devotion. The yoke hung heavy on Whigs
and Tories alike. Even Lord Sidmouth rebelled against the
commercial system to which Perceval clung more desperately than
to his offices or power. “Of that destructive system,” wrote Sidmouth
in the summer of 1810,[236] “all are weary, ‘praeter atrocem animum
Catonis.’”
Even Henry Wellesley, at Seville and Cadiz, felt the same heavy-
hand deadening the effect of every effort, and longed to do at Cadiz
what Erskine had done at Washington. March 4, 1810,[237] Perceval
wrote to Lord Wellesley begging him to instruct his brother Henry to
obtain from the Spanish Junta exclusive or at least special privileges
in the trade of the Spanish colonies, such as would admit British
consuls to the chief places of South America, and “give us a decided
benefit and preference in the trade.” Of course this preference was
to be granted at the expense of the United States, the solitary rival of
England in those waters, but “as nearly hostile to Spain as she can
be without actually declaring war against her.” Soon afterward the
“Espagnol,” a Spanish periodical published in England, applauded
revolutionary movements in Caracas and Buenos Ayres, while it
asserted the impossibility of preventing the spread of the spirit of
independence in the Spanish-American colonies.
“You can have no idea,” wrote Henry Wellesley from Cadiz, August
31, to his brother Arthur,[238] “of the ferment occasioned here by this
article, which is attributed to the Government,—as it is supposed, and
I believe justly, that the ‘Espagnol’ is patronized by the Government,
and contains its sentiments with regard to the occurrences in Spain
and the measures necessary in the present crisis of her affairs.... It is
wonderful that they cannot be satisfied in England with a commercial
arrangement which would be attended with immense advantages to
ourselves, and would likewise be greatly beneficial to Spain. I
apprehend this to be the true spirit of all commercial treaties; and why
are we to take advantage of the weakness of Spain to endeavor to
impose terms upon her which would be ruinous and disgraceful? I
have it in my power to conclude to-morrow a commercial treaty which,
without breaking in upon the Spanish colonial laws, would pour
millions into the pockets of our merchants, and be equally
advantageous to the resources; but this will not do, and we must
either have the trade direct with the colonies, or nothing. However, I
have received my answer, and the Government will not hear of
opening the trade.”
The coincidence of opinion about Spencer Perceval extended
everywhere, except among the Church of England clergy, the
country squires, the shipping interests, the Royal household at
Windsor, and the Federalists of Boston and Connecticut. As though
to make him an object of execration, the long-threatened storm burst
on the trade and private credit of Great Britain. For some eighteen
months gold stood at a premium of about fifteen per cent; the
exchanges remained steadily unfavorable, while credit was strained
to the utmost, until in July, 1810, half the traders in England, and
private banks by the score, were forced to suspend payment. Never
before, and probably never since, has England known such a fall in
prices and destruction of credit.[239]
This was the impending situation when Parliament adjourned,
June 21, with no bright spot on its horizon but the supposed
friendship of America. Meanwhile Pinkney wearied Wellesley for an
answer to the question whether Fox’s blockade was in force. June
10, June 23, and finally August 6, he renewed his formal request.
“No importunity had before been spared which it became me to
use.”[240] He was met by the same torpor at every other point.
Wellesley promised to name a new minister to Washington, but
decided upon none. He invited overtures in regard to the
“Chesapeake” affair, but failed to act on them. Rumor said that he
neglected business, came rarely to Cabinet meetings, shut himself in
his own house, saw only a few friends, and abandoned the attempt
to enforce his views. He resolved to retire from the Cabinet, in
despair of doing good, and waited only for the month before the next
meeting of Parliament, which he conceived to be the most proper
time for declaring his intention.[241]
In the midst of this chaos, such as England had rarely seen, fell
Cadore’s announcement of August 5 that the Imperial Decrees were
withdrawn, bien entendu that before November 1 England should
have abandoned her blockades, or America should have enforced
her rights. Pinkney hastened to lay this information before Lord
Wellesley, August 25, and received the usual friendly promises,
which had ceased to gratify him. “I am truly disgusted with this,” he
wrote home, August 29,[242] “and would, if I followed my own
inclination, speedily put an end to it.” Two days afterward he
received from Wellesley a civil note,[243] saying that whenever the
repeal of the French Decrees should actually have taken effect, and
the commerce of neutral nations should have been restored to the
condition in which it previously stood, the system of counteraction
adopted by England should be abandoned. This reply, being merely
another form of silence, irritated Pinkney still more, while his
instructions pressed him to act. He waited until September 21, when
he addressed to Wellesley a keen remonstrance. “If I had been so
fortunate,” he began,[244] “as to obtain for my hitherto unanswered
inquiry the notice which I had flattered myself it might receive, and to
which I certainly thought it was recommended by the plainest
considerations of policy and justice, it would not perhaps have been
necessary for me to trouble your Lordship with this letter;” and in this
tone he went on to protest against the “unwarrantable prohibitions of
intercourse rather than regular blockades,” which had helped in
nearly obliterating “every trace of the public law of the world”:—
“Your Lordship has informed me in a recent note that it is ‘his
Majesty’s earnest desire to see the commerce of the world restored to
that freedom which is necessary for its prosperity;’ and I cannot
suppose that this freedom is understood to be consistent with vast
constructive blockades which may be so expanded at pleasure as,
without the aid of any new device, to oppress and annihilate every
trade but that which England thinks fit to license. It is not, I am sure, to
such freedom that your Lordship can be thought to allude.”
The Marquess of Buckingham’s well-advised correspondent
some weeks afterward[245] remarked that “Pinkney, who was at first
all sweetness and complaisance, has recently exhibited in his
communications with Lord Wellesley an ample measure of
republican insolence.” Sweetness and insolence were equally thrown
away. Pinkney’s letter of September 21, like most of his other letters,
remained unanswered; and before November 1, when Napoleon’s
term for England’s action expired, a new turn of affairs made answer
impossible. The old King was allowed to visit the death-bed of his
favorite daughter the Princess Amelia; he excited himself over her
wishes and farewells, and October 25 his mind, long failing, gave
way for the last time. His insanity could not be disguised, and the
Government fell at once into confusion.
CHAPTER XIV.
The summer of 1810 was quiet and hopeful in America. For the
first time since December, 1807, trade was free. Although little
immigration occurred, the census showed an increase in population
of nearly thirty-seven per cent in ten years,—from 5,300,000 to
7,240,000, of which less than one hundred thousand was due to the
purchase of Louisiana. Virginia and Massachusetts still fairly held
their own, and New York strode in advance of Pennsylvania, while
the West gained little relative weight. Ohio had not yet a quarter of a
million people, Indiana only twenty-four thousand, and Illinois but
twelve thousand, while Michigan contained less than five thousand.
The third census showed no decided change in the balance of power
from any point of view bounded by the usual horizon of human life.
Perhaps the growth of New York city and Philadelphia pointed to a
movement among the American people which might prove more
revolutionary than any mere agricultural movement westward. Each
of these cities contained a population of ninety-six thousand, while
Baltimore rose to forty-six thousand, and Boston to thirty-two
thousand. The tendency toward city life, if not yet unduly great, was
worth noticing, especially because it was confined to the seaboard
States of the North.
The reason of this tendency could in part be seen in the Treasury
reports on American shipping, which reached in 1810 a registered
tonnage of 1,424,000,—a point not again passed until 1826. The
registered foreign tonnage sprang to 984,000,—a point not again
reached in nearly forty years. New vessels were built to the amount
of one hundred and twenty-seven thousand tons in the year 1810.
[246] The value of all the merchandise exported in the year ending
Sept. 30, 1810, amounted to nearly sixty-seven million dollars, and
of this sum about forty-two millions represented articles of domestic
production.[247] Except in the year before the embargo this export of
domestic produce had never been much exceeded.[248] The imports,
as measured by the revenue, were on the same scale. The net
customs-revenue which reached $16,500,000 in 1807, after falling in
1808 and 1809 to about $7,000,000, rose again to $12,750,000 in
1810.[249] The profits of the export and import business fell chiefly to
Boston, New York, Philadelphia, and Baltimore, where the shipping
belonged; and these cities could not fail to attract labor as well as
capital beyond the degree that a conservative republican of the
Revolutionary time would have thought safe.
More than half of these commercial exchanges were with
England or her dependencies. Great Britain and her American
colonies, Portugal and Spain in her military protection, and British
India consumed at least one half of the exports; while of the net
revenue collected on imports, Gallatin estimated six and a half
millions as derived from articles imported from Great Britain and the
British dependencies, all other sources supplying hardly six millions.
[250] The nature of these imports could be only roughly given. In
general, sugar, molasses, coffee, wines, silk, and tea were not
British; but manufactures of cotton, linen, leather, paper, glass,
earthen-ware, iron, and other metals came chiefly from Great Britain.
To the United States this British trade brought most of the articles
necessary to daily comfort in every part of the domestic economy.
The relief of recovering a full and cheap supply exceeded the
satisfaction of handsome profits on the renewed trade. Experience of
the hourly annoyance, expense, and physical exposure caused by
deprivation of what society considered necessities rendered any
return to the restrictive system in the highest degree unwise,
especially after the eastern people acquired conviction that the
system had proved a failure.
Thus the summer passed with much of the old contentment that
marked the first Administration of Jefferson. Having lost sight of
national dignity, the commercial class was contented under the
protection of England; and American ships in the Baltic, in Portugal,
and in the West Indies never hesitated to ask and were rarely
refused the assistance of the British navy. From time to time a few
impressments were reported; but impressment had never been the
chief subject of complaint, and after the withdrawal of the frigates
blockading New York, little was heard of British violence. On the
other hand, Napoleon’s outrages roused great clamor in commercial
society, and his needless harshness to every victim, from the Pope
to the American sailors whom he shut up as prisoners of war, went
far to palliate British offences in the eyes of American merchants.
News of Napoleon’s seizures at San Sebastian arrived before the
adjournment of Congress May 1; and as fresh outrages were
reported from every quarter by every new arrival, and as Cadore’s
letters became public, even Madison broke into reproaches. May 25
he wrote to Jefferson:[251] “The late confiscations by Bonaparte
comprise robbery, theft, and breach of trust, and exceed in turpitude
any of his enormities not wasting human blood.” These words
seemed to show intense feeling, but Madison’s temper indulged in
outbursts of irritability without effect on his action; in reality, his mind
was bent beyond chance of change on the old idea of his
Revolutionary education,—that the United States must not regard
France, but must resist Great Britain by commercial restrictions.
“This scene on the Continent,” he continued to Jefferson, “and the
effect of English monopoly on the value of our produce are breaking
the charm attached to what is called free-trade, foolishly by some
and wickedly by others.” He reverted to his life-long theory of
commercial regulations.
A few days afterward Madison wrote to Armstrong fresh
instructions founded on the Act of May 1, which was to be the new
diplomatic guide. These instructions,[252] dated June 5, were of
course signed by the Secretary of State, Robert Smith, who
afterward claimed credit for them; but their style, both of thought and
expression, belonged to Madison. Even the unfailing note of his mind
—irritability without passion—was not wanting. He would wait, he
said, for further advices before making the proper comments on
Cadore’s letter of February 14 and on its doctrine of reprisals. “I
cannot, however, forbear informing you that a high indignation is felt
by the President, as well as by the public, at this act of violence on
our property, and at the outrage both in the language and in the
matter of the letter of the Duc de Cadore.” Turning from this subject,
the despatch requested that Napoleon would make use of the
suggestion contained in the Act of May 1, 1810. “If there be sincerity
in the language held at different times by the French government,
and especially in the late overture, to proceed to amicable and just
arrangements in case of our refusal to submit to the British Orders in
Council, no pretext can be found for longer declining to put an end to
the decrees of which the United States have so justly complained.”
One condition alone was imposed on Armstrong preliminary to the
acceptance of French action under the law of May 1, but this
condition was essential:
“If, however, the arrangement contemplated by the law should be
acceptable to the French government, you will understand it to be the
purpose of the President not to proceed in giving it effect in case the
late seizure of the property of the citizens of the United States has
been followed by an absolute confiscation, and restoration be finally
refused. The only ground short of a preliminary restoration of the
property on which the contemplated arrangement can be made will be
an understanding that the confiscation is reversible, and that it will
become immediately the subject of discussion with a reasonable
prospect of justice to our injured citizens.”
The condition thus prescribed seemed both reasonable and mild
in view of the recent and continuous nature of the offence; but
Madison could not, even if he would, allow his own or public
attention to be permanently diverted from England. As early as June
22 he had begun to reconstruct in his own mind the machinery of his
restrictive system. “On the first publication of the despatches by the
‘John Adams,’” he wrote to Jefferson,[253] “so strong a feeling was
produced by Armstrong’s picture of the French robbery that the
attitude in which England was placed by the correspondence
between Pinkney and Wellesley was overlooked. The public
attention is beginning to fix itself on the proof it affords that the
original sin against neutrals lies with Great Britain; and that while she
acknowledges it, she persists in it.”
The theory of original sin led to many conclusions hard to
reconcile; but, as regarded Napoleon, Madison’s idea seemed both
sensible and dignified,—that England’s original fault in no way
justified the recent acts of France, which were equivalent to war on
the United States, not as one among neutrals, but as a particular
enemy. Fresh instructions to Armstrong, dated July 5,[254] reiterated
the complaints, offers, and conditions of the despatch sent one
month before. Especially the condition precedent to action under the
law of May 1 was repeated with emphasis:—
“As has been heretofore stated to you, a satisfactory provision for
restoring the property lately surprised and seized, by the order or at
the instance of the French government, must be combined with a
repeal of the French edicts with a view to a non-intercourse with Great
Britain, such a provision being an indispensable evidence of the just
purpose of France toward the United States. And you will moreover be
careful, in arranging such a provision for that particular case of
spoliations, not to weaken the ground on which a redress of others
may be justly pursued.”
The instructions of June 5 and July 5 went their way; but although
Armstrong duly received them, and wrote to Cadore a letter evidently
founded on the despatch of June 5, he made no express allusion to
his instructions in writing either to the French government or to his
own. Although he remained in Paris till September 12, and on that
day received from Cadore an explicit avowal that the sequestered
property would not be restored, but that “the principles of reprisal
must be the law,” he made no protest.
Equally obscure was the conduct of Madison. Cadore’s letter of
August 5 announcing that the French Decrees were withdrawn, on
the understanding that the United States should by November 1
enforce their rights against England, reached Washington
September 25, but not in official form. Nothing is known of the
impression it produced on the Cabinet; nothing remains of any
discussions that ensued. If Gallatin was consulted, he left no trace of
his opinion. Hamilton and Eustis had little weight in deciding foreign
questions. Robert Smith within a year afterward publicly attacked the
President for the course pursued, and gave the impression that it
was taken on Madison’s sole judgment. The President’s only
authority to act at all without consulting Congress depended on the
words of the law of May 1: “In case either Great Britain or France
shall, before the third day of March next, so revoke or modify her
edicts as that they shall cease to violate the neutral commerce of the
United States, which fact the President of the United States shall
proclaim by proclamation,” the non-intercourse of March 1, 1809,
should at the end of three months revive against the nation which
had not revoked its edicts. Under this authority, President Madison
was required by Cadore’s letter to proclaim that France had revoked
or modified her edicts so that they ceased to violate the neutral
commerce of the United States.
Madison was doubtless a man of veracity; but how was it
possible that any man of veracity could proclaim that France had
revoked or modified her edicts so that they ceased to violate the
neutral commerce of the United States when he had every reason to
think that at least the Bayonne Decree, barely six months old, would
not be revoked, and when within a few weeks he had officially
declared that the revocation of the Bayonne Decree was “an
indispensable evidence of the just purpose of France” preliminary to
a non-intercourse with England? If the President in June and July
thought that provision indispensable to the true intent of the law
which he aided in framing, he would assume something more than
royal dispensing power by setting the indispensable provision aside
in November.
This objection was light in comparison with others. The law
required the President to proclaim a fact,—that France had revoked
or modified her decrees so that they ceased to violate the commerce
of America. Of this fact Cadore’s letter was the only proof; but
evidently Cadore’s letter pledged the Emperor to nothing. “I am
authorized to declare to you,” wrote Cadore, “that the Decrees of
Berlin and Milan are revoked, and that after November 1 they will
cease to have effect, on the understanding that in consequence of
this declaration ... the United States, conformably to the Act you
have just communicated, shall cause their rights to be respected by
the English.” Napoleon not only reserved to himself the right of
judging whether the measures to be taken by the United States
should “cause their rights to be respected,” but in doing so he
reversed the process prescribed by the Act, and required the
President to enforce his rights before the Emperor should withdraw
his decrees.
From the standpoint of morality, perhaps the most serious
objection of all was the danger of sacrificing national and personal
self-respect by affecting to regard as honest a promise evidently
framed to deceive, and made by a man whom Madison habitually
characterized in terms that implied, to speak mildly, entire want of
confidence. If America would consent to assert her rights against
England in no way more straightforward than this, she might perhaps
recover her neutral profits, but hardly her national self-respect.
A few months afterward, when Robert Smith gave to the world
the amusing but not wholly new spectacle of a Secretary of State
attacking his own President for measures signed by his own name,
Joel Barlow wrote for the “National Intelligencer” a defence of the
President’s course, in which he gave reasons supplied by Madison
himself for holding that Cadore’s letter satisfied the conditions of
Macon’s Act.
To the first objection, founded on the Rambouillet and Bayonne
Decrees, Barlow replied that the American government had
habitually distinguished between maritime edicts violating neutral
rights and municipal edicts attacking private property. “We could not
in strictness arraign such municipal spoliations under the head of
violations of our neutral rights, nor of consequence regard them as
contemplated by the Acts of Congress defining the acts whose
revocation would satisfy the conditions of that Act.” This reasoning,
though not quite convincing, might have had weight but for two
objections. First, the President himself, in June and July, had
declared these municipal spoliations to be contemplated by Macon’s
Act as “an indispensable evidence of the just purpose of
France;”[255] and, second, the President in November notified
Armstrong, that,[256] “in issuing the proclamation, it has been
presumed that the requisition contained in that letter [of July 5] on
the subject of the sequestered property will have been satisfied.”
Barlow’s idea of a municipal spoliation, independent of the jus
gentium, was an afterthought intended to hide a miscalculation.
One other argument was advanced by Barlow. Erskine’s
arrangement having been accepted without question of previous
British spoliations, not only did impartiality require the same
treatment for France, but a different rule “would have led to the
embarrassment of obliging the Executive, in case the British
government should be desirous of opening a free trade with the
United States by repealing its orders, to make it a prerequisite that
Great Britain also should indemnify for her respective spoliations.”
Such a prerequisite would have been proper, and ought to have
been imposed; but Barlow’s argument was again answered by the
President himself, who actually insisted on the demand against
France, and assumed the demand to be satisfied. If this was
partiality to England, the President was guilty of it. Probably at the
time he saw reasons for thinking otherwise. The secrecy, the
continuance, the pretext of the French seizures, their municipal and
vindictive character and direct Imperial agency seemed to set them
apart from those of England, which, although equally illegal, were
always in the form of lawful trial and condemnation.
The same argument of impartiality served to justify immediate
action on Cadore’s offer as on Erskine’s, without waiting for its
execution. That one admitted mistake excused its own repetition in a
worse form was a plea not usually advanced by servants, either
public or private; but in truth Erskine’s pledge was distinct and
unconditional, while Cadore’s depended on the Emperor’s
satisfaction with a preliminary act. Had Erskine made his
arrangement conditional on Canning’s approval of the President’s
measures, Madison would certainly have waited for that approval
before acting under the law; and after the disastrous results of
precipitancy in 1809, when no one questioned Erskine’s good faith,
wisdom called for more caution rather than less in acting, in 1810, on
an offer or a pledge from a man in whom no one felt any confidence
at all.
In truth, Madison’s course in both cases was due not to logic, but
to impatience. As Barlow admitted: “We know it had been the aim of
our government for two or three years to divide the belligerents by
inducing one or the other of them to revoke its edicts, so that the
example would lead to a revocation by the other, or our contest be
limited to a single one.” Madison gave the same reason in a letter of
October 19 to Jefferson:[257] “We hope from the step the advantage
at least of having but one contest on our hands at a time.” He was
mistaken, and no one expressed himself afterward in language more
bitter than he used against Napoleon for conduct that deceived only
those who lent themselves to deception.
October 31, Robert Smith sent for Turreau and gave him notice of
the decision reached by the President and Cabinet:[258]—
“The Executive,” said Robert Smith, “is determined not to suffer
England longer to trammel the commerce of the United States, and he
hopes to be sustained by Congress. If, then, England does not
renounce her system of paper-blockades and the other vexations
resulting from it, no arrangement with that Power is to be expected;
and consequently you will see, in two days, the President’s
proclamation appear, founded on the provisions of the law requiring
the non-intercourse to be enforced against either nation which should
fail to revoke its edicts after the other belligerent had done so....
Although we have received nothing directly from Mr. Armstrong on this
subject, which is doubtless very extraordinary, we consider as
sufficient for the Government’s purposes the communication he made
to Mr. Pinkney, which the latter has transmitted to us.”
The next day Robert Smith made some further interesting
remarks.[259] “The Executive thinks,” he said, “that the measures he
shall take in case England continues to restrict our communications
with Europe will lead necessarily to war,” because of the terms of the
non-intercourse. “We have with us a majority of Congress, which has
much to retrieve, and has been accused of weakness by all parties.”
On leaving Smith, Turreau went to see Gallatin, “whose opinion in
the Cabinet is rarely favorable to us.”
“Mr. Gallatin (by the way long since on bad terms with Mr. Smith)
told me that he believed in war; that England could not suffer the
execution of measures so prejudicial to her, and especially in the
actual circumstances could not renounce the prerogatives of her
maritime supremacy and of her commercial ascendency.”
Both Smith and Gallatin evidently expected that war was to
result, not from the further action of the United States, but from the
resentment and retaliation of England. They regarded the non-
intercourse as a measure of compulsion which would require
England either to resent it or to yield.
Having decided to accept Cadore’s letter as proof that an actual
repeal of the French Decrees, within the meaning of the Act of
Congress, had taken place November 1, the President issued,
November 2, his proclamation declaring that “it has been officially
made known to this Government that the said edicts of France have
been so revoked as that they ceased, on the said first day of the
present month, to violate the neutral commerce of the United
States;” and simultaneously Gallatin issued a circular to the
collectors of customs, announcing that commercial intercourse with
Great Britain would cease Feb. 2, 1811.
By this means Madison succeeded in reverting to his methods of
peaceful coercion. As concerned England, he could be blamed only
on the ground that his methods were admittedly inadequate, as
Gallatin, only a year before, had officially complained. Toward
England the United States had stood for five years in a position
which warranted them in adopting any measure of reprisal. The
people of America alone had a right to object that when Madison
began his attack on England by proclaiming the French Decrees to
be revoked, he made himself a party to Napoleon’s fraud, and could
scarcely blame the Federalists for replying that neither in honor nor
in patriotism were they bound to abet him in such a scheme.
The Proclamation of Nov. 2, 1810, was not the only measure of
the autumn which exposed the President to something more severe
than criticism. At the moment when he challenged a contest with
England on the assertion that Napoleon had withdrawn his decrees,
Madison resumed his encroachments on Spain in a form equally
open to objection.
The chaos that reigned at Madrid and Cadiz could not fail to
make itself felt throughout the Spanish empire. Under British
influence, Buenos Ayres in 1810 separated from the Supreme Junta,
and drove out the viceroy whom the Junta had appointed. In April of
the same year Caracas followed the example, and entered into a
treaty with England, granting commercial preferences equally
annoying to the Spaniards and to the United States. Miranda
reappeared at the head of a revolution which quickly spread through
Venezuela and New Grenada. A civil war broke out in Mexico. Even
Cuba became uneasy. The bulky fabric of Spanish authority was
shaken, and no one doubted that it must soon fall in pieces forever.
England and the United States, like two vultures, hovered over
the expiring empire, snatching at the morsels they most coveted,
while the unfortunate Spaniards, to whom the rich prey belonged,
flung themselves, without leadership or resources, on the ranks of
Napoleon’s armies. England pursued her game over the whole of
Spanish America, if not by government authority, more effectively by
private intrigue; while the United States for the moment confined
their activity to a single object, not wholly without excuse.
As long as Baton Rouge and Mobile remained Spanish, New
Orleans was insecure. This evident danger prompted Madison, when
Secretary of State, to make a series of efforts, all more or less
unfortunate, to gain possession of West Florida; and perhaps
nothing but Napoleon’s positive threat of war prevented the seizure
of Baton Rouge during Jefferson’s time. After that crisis, the subject
dropped from diplomatic discussion; but as years passed, and
Spanish power waned, American influence steadily spread in the
province. Numerous Americans settled in or near the district of West
Feliciana, within sight of Fort Adams, across the American border.
As their number increased, the Spanish flag at Baton Rouge became
less and less agreeable to them; but they waited until Buenos Ayres
and Caracas gave notice that Spain could be safely defied.
In the middle of July, 1810, the citizens of West Feliciana
appointed four delegates to a general convention, and sent
invitations to the neighboring districts inviting them to co-operate in
re-establishing a settled government. The convention was held July
25, and consisted of sixteen delegates from four districts, who
organized themselves as a legislature, and with the aid or consent of
the Spanish governor began to remodel the government. After some
weeks of activity they quarrelled with the governor, charged him with
perfidy, and suddenly assembling all the armed men they could
raise, assaulted Baton Rouge. The Spanish fort, at best incapable of
defence, was in charge of young Louis Grandpré, with a few invalid
or worthless soldiers. The young man thought himself bound in
honor to maintain a trust committed to him; he rejected the summons
to surrender, and when the Americans swarmed over the ruinous
bastions they found Louis Grandpré alone defending his flag. He
was killed.
After capturing Baton Rouge, the Americans held a convention,
which declared itself representative of the people of West Florida,
and September 26 issued a proclamation, which claimed place
among the curious products of that extraordinary time. “It is known to
the world,” began this new declaration of independence,[260] “with
how much fidelity the good people of this territory have professed
and maintained allegiance to their legitimate sovereign while any
hope remained of receiving from him protection for their property and
lives.” The convention had acted in concert with the Spanish
governor “for the express purpose of preserving this territory, and
showing our attachment to the government which had heretofore
protected us;” but the governor had endeavored to pervert those
concerted measures into an engine of destruction; and therefore,
“appealing to the Supreme Ruler of the world for the rectitude of our
intentions, we do solemnly publish and declare the several districts
composing the territory of West Florida to be a free and independent
State.”
A few days afterward the convention, through its president, wrote
to the Secretary of State, Robert Smith, urging the annexation of the
new territory to the United States, but claiming all the public lands in
the province for “the people of this Commonwealth, who have
wrested the government and country from Spain at the risk of their
lives and fortunes.”[261] These words accorded ill with their appeal to
the Supreme Ruler of the world for the rectitude of their intentions,
and their protest of “our inviolable fidelity to our king and parent
country while so much as a shadow of legitimate authority remained
to be exercised over us.” Yet neither with nor without their elaborate
machinery of legitimate revolution could Madison have anything to
do with them. Innumerable obstacles stood in his way. They declared
the independence of territory which he had long since appropriated
to the United States. This course alone withheld Madison from
recognizing the new State; but other difficulties forbade any action at
all. The Constitution gave the President no power to use the army or
navy of the United States beyond the national limits, without the
authority of Congress; and although extreme emergency might have
excused the President in taking such action, no emergency existed
in October, 1810, since Congress would meet within six weeks, and
neither Spain, France, nor England could interfere in the interval.
The President’s only legal course was to wait for Congress to take
what measures seemed good.
Madison saw all this, but though aware of his want of authority,
felt the strongest impulse to act without it. He described his dilemma
to Jefferson in a letter written before he received the request for
annexation, then on its way from Baton Rouge:[262]—
“The crisis in West Florida, as you will see, has come home to our
feelings and interests. It presents at the same time serious questions
as to the authority of the Executive, and the adequacy of the existing
laws of the United States for territorial administration. And the near
approach of Congress might subject any intermediate interposition of
the Executive to the charge of being premature and disrespectful, if
not of being illegal. Still, there is great weight in the considerations
that the country to the Perdido, being our own, may be fairly taken
possession of, if it can be done without violence; above all, if there be
danger of its passing into the hands of a third and dangerous party.”
Casuistry might carry the United States government far. The
military occupation of West Florida was an act of war against Spain.
“From present appearances,” continued Madison, “our occupancy of
West Florida would be resented by Spain, by England, and by
France, and bring on, not a triangular, but quadrangular contest.”
Napoleon himself never committed a more arbitrary act than that of
marching an army, without notice, into a neighbor’s territory, on the
plea that he claimed it as his own. None of Madison’s predecessors
ventured on such liberties with the law; none of his successors dared
imitate them, except under the pretext that war already existed by
the act of the adverse government.
Madison was regarded by his contemporaries as a precise, well-
balanced, even a timid man, argumentative to satiety, never carried
away by bursts of passion, fretful rather than vehement, pertinacious
rather than resolute,—a character that seemed incapable of
surprising the world by reckless ambition or lawless acts; yet this
circumspect citizen, always treated by his associates with a shade of
contempt as a closet politician, paid surprisingly little regard to rules
of consistency or caution. His Virginia Resolutions of 1798, his
instructions in the Louisiana purchase, his assumption of
Livingston’s claim to West Florida, his treatment of Yrujo, his
embargo policy, his acceptance of Erskine’s arrangement, his
acceptance of Cadore’s arrangement, and his occupation of West
Florida were all examples of the same trait; and an abundance of
others were to come. He ignored caution in pursuit of an object
which seemed to him proper in itself; nor could he understand why
this quiet and patriotic conduct should rouse tempests of passion in
his opponents, whose violence, by contrast, increased the apparent
placidity of his own persistence.
Forestalling the action of Congress which was to meet within five
weeks, President Madison issued, Oct. 27, 1810, a proclamation
announcing that Governor Claiborne would take possession of West
Florida to the river Perdido, in the name and behalf of the United
States. This proclamation, one of the most remarkable documents in
the archives of the United States government, began by reasserting
the familiar claim to West Florida as included in the Louisiana
purchase:—
“And whereas the acquiescence of the United States in the
temporary continuance of the said territory under the Spanish
authority was not the result of any distrust of their title, as has been
particularly evinced by the general tenor of their laws and by the
distinction made in the application of those laws between that territory
and foreign countries, but was occasioned by their conciliatory views,
and by a confidence in the justice of their cause, and in the success of
candid discussion and amicable negotiation with a just and friendly
Power; ... considering, moreover, that under these peculiar and
imperative circumstances a forbearance on the part of the United
States to occupy the territory in question, and thereby guard against
the confusions and contingencies which threaten it, might be
construed into a dereliction of their title or an insensibility to the
importance of the stake; considering that in the hands of the United
States it will not cease to be a subject of fair and friendly negotiation
and adjustment; considering finally that the Acts of Congress, though
contemplating a present possession by a foreign authority, have
contemplated also an eventual possession of the said territory by the
United States, and are accordingly so framed as in that case to extend
in their operation to the same,”—
Considering all these reasons, substantially the same self-
interest by which France justified her decrees, and England her
impressments, the President ordered Governor Claiborne, with the
aid of the United States army, to occupy the country and to govern it
as a part of his own Orleans territory.[263] By a letter of the same
date the Secretary of State informed Claiborne, that, “if contrary to
expectation, the occupation of this [revolutionized] territory should be
opposed by force, the commanding officer of the regular troops on
the Mississippi will have orders from the Secretary of War to afford
you, upon your application, the requisite aid.... Should however any
particular place, however small, remain in possession of a Spanish
force, you will not proceed to employ force against it, but you will
make immediate report thereof to this Department.”[264] Having by
these few strokes of his pen authorized the seizure of territory
belonging to “a just and friendly Power,” and having legislated for a
foreign people without consulting their wishes, the President sent to
the revolutionary convention at Baton Rouge a sharp message
through Governor Holmes of the Mississippi territory, to the effect
that their independence was an impertinence, and their designs on
the public lands were something worse.[265]
A few days after taking these measures, Robert Smith explained
their causes to Turreau in the same conversation in which he
announced the decision to accept Cadore’s letter as the foundation
of non-intercourse with England. The wish to preclude British
occupation of Florida was the motive alleged by Smith for the
intended occupation by the United States.[266]
“As for the Floridas, I swear, General, on my honor as a
gentleman,” said Robert Smith to Turreau, October 31, “not only that
we are strangers to everything that has happened, but even that the
Americans who have appeared there either as agents or leaders are
enemies of the Executive, and act in this sense against the Federal
government as well as against Spain.... Moreover these men and
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like