100% found this document useful (2 votes)
26 views

Numerical Methods using MATLAB Gupta pdf download

The document provides information about the book 'Numerical Methods using MATLAB' by Abhishek Gupta, detailing its content structure and approach to teaching numerical methods through practical examples in MATLAB. It emphasizes the importance of hands-on learning and covers various topics including matrix operations, simulations, optimization, and differential equations. The book is designed for users with basic MATLAB knowledge and aims to facilitate quick and effective problem-solving in research and engineering applications.

Uploaded by

jonticliping
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
26 views

Numerical Methods using MATLAB Gupta pdf download

The document provides information about the book 'Numerical Methods using MATLAB' by Abhishek Gupta, detailing its content structure and approach to teaching numerical methods through practical examples in MATLAB. It emphasizes the importance of hands-on learning and covers various topics including matrix operations, simulations, optimization, and differential equations. The book is designed for users with basic MATLAB knowledge and aims to facilitate quick and effective problem-solving in research and engineering applications.

Uploaded by

jonticliping
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Numerical Methods using MATLAB Gupta pdf

download

https://ebookfinal.com/download/numerical-methods-using-matlab-
gupta/

Explore and download more ebooks or textbooks


at ebookfinal.com
Here are some recommended products for you. Click the link to
download, or explore more at ebookfinal

Numerical Methods Third Edition Using MATLAB George


Lindfield

https://ebookfinal.com/download/numerical-methods-third-edition-using-
matlab-george-lindfield/

Numerical methods using MATLAB 4th Edition John. H.


Mathews

https://ebookfinal.com/download/numerical-methods-using-matlab-4th-
edition-john-h-mathews/

An Introduction to Numerical Methods A MATLAB Approach


Third Edition Guenther

https://ebookfinal.com/download/an-introduction-to-numerical-methods-
a-matlab-approach-third-edition-guenther/

Numerical Methods in Finance A MATLAB Based Introduction


1st Edition Paolo Brandimarte

https://ebookfinal.com/download/numerical-methods-in-finance-a-matlab-
based-introduction-1st-edition-paolo-brandimarte/
Applied Numerical Methods with MATLAB for Engineers and
Scientists 2nd ed Edition Steven C. Chapra

https://ebookfinal.com/download/applied-numerical-methods-with-matlab-
for-engineers-and-scientists-2nd-ed-edition-steven-c-chapra/

Computing for Numerical Methods Using Visual C 1st edition


Edition Shaharuddin Salleh

https://ebookfinal.com/download/computing-for-numerical-methods-using-
visual-c-1st-edition-edition-shaharuddin-salleh/

Numerical Techniques in Electromagnetics with MATLAB Third


Edition Matthew N.O. Sadiku

https://ebookfinal.com/download/numerical-techniques-in-
electromagnetics-with-matlab-third-edition-matthew-n-o-sadiku/

Numerical Methods 4th Edition George Lindfield

https://ebookfinal.com/download/numerical-methods-4th-edition-george-
lindfield/

Numerical Methods 1st Edition S.R.K.Iyengar & R.K. Jain

https://ebookfinal.com/download/numerical-methods-1st-edition-s-r-k-
iyengar-r-k-jain/
Numerical Methods using MATLAB Gupta Digital
Instant Download
Author(s): Gupta, Abhishek
ISBN(s): 9781484201541, 148420154X
Edition: Online-ausg
File Details: PDF, 5.83 MB
Year: 2015
Language: english
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
Contents at a Glance

About the Author ...............................................................................................................xiii


Acknowledgments .............................................................................................................. xv
Introduction ...................................................................................................................... xvii

N Chapter 1: Introduction to MATLAB ...................................................................................1


N Chapter 2: Matrix Representation, Operations and Vectorization ...................................13
N Chapter 3: Numerical Techniques ....................................................................................27
N Chapter 4: Visualization ..................................................................................................39
N Chapter 5: Introduction to Simulation .............................................................................49
N Chapter 6: Monte Carlo Simulations ................................................................................69
N Chapter 7: Optimization ...................................................................................................81
N Chapter 8: Evolutionary Computations ............................................................................93
N Chapter 9: Regression and Model Fitting ......................................................................107
N Chapter 10: Differential Equations and System Dynamics ............................................119

Index .................................................................................................................................133

v
Introduction

I had my first experience with MATLAB in my second year of engineering while working on control systems design.
Later on, in my internship, I got an opportunity to develop a package named MAD in MATLAB under Dr Shaun
A Forth at DCMT, UK. From there on, my interest in MATLAB kept on increasing. The journey thus started never
stopped and MATLAB has become an inseparable component of my research life. I have become a big fan of MATLAB
due to its simplicity and its vectorization capability. I enjoy programming in MATLAB. This book is my attempt to
make others a fan of it too.
This book presents a wide range of numerical methods and their implementation in MATLAB with the help of
examples to make the learning more interactive. A conventional method to teach numerical methods is to first give
a detailed discussion of such methods and then present a few examples. This method is very far from being efficient
and by the time the actual implementation comes, the user who is mainly interested in solving his own problems
has already given up. This book takes a very different approach by stressing the concept of trying out techniques by
oneself, and attempts to start the discussion with examples long before the actual theory is introduced. The idea
behind the book came to me when I taught a course on MATLAB to a small batch of students at my home institution.
During the course, I had encountered the problems which students face while learning it. As a student and researcher
I understand what a researcher or student looks for in a book and hence I believe this book will prove to be valuable
to the intended audience. Instead of bombarding users with theory and information, the book only gives concise and
practical information to help you to effectively solve your research problem in less time.
This book presents each and every topic in a very concise and readable format which helps you to learn quickly
and effectively. This book can also serve as a complementary book for a MATLAB course in engineering colleges.
Also, it is designed to be a companion in your research anywhere you go. This book assumes that the user has a
basic knowledge of MATLAB programming and quickly covers the MATLAB basics in the first chapter. If the user is
not familiar with MATLAB, he should read some basic MATLAB books prior to starting this book. One such book is
written by me and titled “MATLAB by Examples”, published by Finch Publications (2010).
This book is divided into 10 chapters. The first two chapters are written to help users to quickly understand
MATLAB. Chapter 1 covers the basic programming paradigm of MATLAB, including how to write functions, scripts
and data structures. Chapter 2 quickly covers one of the most important features of MATLAB known as vectorization,
which will help you to write efficient programs in MATLAB.
The third chapter is probably the most important chapter and provides the foundation of the book. It covers
all the important operations basic to any numerical computation. Once the user is familiar with these fundamental
operations and learns how to implement them, the rest of the book should come naturally to him.
The fourth chapter provides a quick tutorial for visualizing any output and results in MATLAB using simple plots
and animations.
The fifth chapter discusses the primary concepts and methodology behind any numerical simulation. It talks
about how we can solve any numerical computations using MATLAB and presents some key examples to elaborate
on the topics more clearly. Building on the fifth chapter, the sixth chapter incorporates random components in any
system or simulation and introduces the idea behind Monte Carlo simulations.

xvii
N INTRODUCTION

Chapter 7 acquaints you with the powerful tool of optimization in MATLAB. Since MATLAB provides a wide
range of inbuilt functions to solve any optimization problem, this chapter gives a comprehensive review of all the
important methods. However, learning to implement such methods from scratch is also crucial to developing a proper
understanding and approach towards numerical methods. The chapter also elaborates on the paradigm behind
the full implementation of such methods with examples. Building on this, Chapter 8 presents a brief but complete
description of evolutionary algorithms such as the genetic algorithm and swarm intelligence algorithms, e.g. particle
swarm optimization.
Chapter 9 is written for data scientists and statisticians. Regression and model fitting play an important role in all
modern era applications, be it time-series analysis or market prediction in the financial domain or the recommender
system in online economics. This chapter covers the main approach behind regression with an appropriate amount of
theory to provide an optimal reading and learning experience for the users.
Chapter 10 is written for control system engineers and researchers interested in understanding the dynamics of
any system. It is built on Chapters 5 and 6 and, using tools from these two chapters and inbuilt functions, it provides
a concise yet detailed overview of simulating the dynamics and time evolution of real world continuous and discrete
systems.

xviii
CHAPTER 1

Introduction to MATLAB

In this chapter, we will talk about the basics of MATLAB and how to get started with it. We expect the reader to have
basic programming skills, and therefore we will not cover any MATLAB programming concepts in detail. When
discussing any topic, we will try not to go into such specifics that cause us to deviate from our main goal. Instead,
we will provide proper references which can be consulted for more information.

Introduction
MATLAB is a programming language created with the basic goal of providing a simple intuitive platform for
engineering design applications. However, as well as being a programming language, it can also be classified as
software for computation and visualization. On one hand, you can call sophisticated programming routines in
MATLAB, while on the other hand you can just open a simple graphical user interface to fill in the specifications,
click OK, and MATLAB will perform computations and visualize it for you.
As we will see in later chapters, most engineering tasks require processing of matrices, for example image
processing or data regression. MATLAB provides an excellent platform and routines for matrix operations. In fact,
MATLAB is short for MATrix LABoratory because its main feature is to provide direct operations on matrices and to
avoid complicated loops.
Current engineering applications use numerical simulations extensively, which require specific functions along
with a programming language. For example, a signal processing application will need filter, fft and similar basic
functions. In typical programming environments such as C/C++, you need to write these basic functions yourself.
MATLAB provides all such basic and advanced functions in built-in packages known as toolboxes. MATLAB currently
has a wide range of toolboxes for different engineering fields, e.g. it has toolboxes devoted to signal processing, image
processing, communication, control systems and finance. In addition, some engineers are more inclined towards
graphical models and want to avoid writing programming routines. MATLAB also features Simulink, which provides a
platform for building and simulating graphical models without knowledge of programming.
MATLAB provides an interactive environment to perform engineering tasks for most current fields. You can also
use your own toolboxes or use extra toolboxes built by others, which are freely available at the MATLAB File exchange
at the following address:

http://http://www.mathworks.com/matlabcentral/fileexchange.

With its intuitive language, minimalistic programming commands, capability of one shot matrix operations,
a wide range of toolboxes for most engineering fields, interactive platform and excellent visualization capabilities,
MATLAB is regarded as an excellent and preferred tool for academic research and industrial applications.

1
CHAPTER 1 N INTRODUCTION TO MATLAB

Interface
After you have successfully installed MATLAB, you can open it by double clicking the icon or typing matlab in the
terminal/run window. Depending on your machine, you will see something like Figure 1-1. The whole interface
is known as the MATLAB Desktop. It consists of many components and windows which can be reorganized and
enabled/disabled by mouse actions or via Desktop ° Layout menu options. Here are some of the important
components one can find in a standard MATLAB Desktop:

Figure 1-1. MATLAB Desktop

Command Window
The command window can be considered as a terminal. It is shown at the bottom of the middle column in Figure 1-1.
Here, you can type your commands and run MATLAB programs (known as scripts). MATLAB displays >> as the
command prompt.

Current Directory
The Current Directory in MATLAB represents a directory in which MATLAB looks for the functions and program files.
In order to run a program, it must be in the current directory. The Current Directory window shows all the files and
folders in the current directory. You can change the current directory or even add some folders to the MATLAB
search path.

2
CHAPTER 1 N INTRODUCTION TO MATLAB

Workspace
The MATLAB workspace contains all the variables present and is shown at the top right of Figure 1-1. MATLAB
programming differs from conventional programming languages in the sense that any variables created during a
program execution remain, even after the program has executed, until you explicitly clear them or close the
MATLAB session.

Figures
MATLAB uses figure windows to display any plot or visualization. This is shown in the leftmost column of Figure 1-1.
We can open multiple figure windows using the figure command.

Command History
The command history window stores and displays all previous MATLAB commands issued in the command window.
You can rerun any command by double clicking on the command window. We can also access the command via the
keyboard, using the up and down arrow keys.

Editor
MATLAB provides an integrated editor to write commands and programs and execute them. The editor also can be
used to debug programs. It is shown at the top middle of Figure 1-1.

Help Browser
MATLAB provides excellent documentation for all its functions with sufficient examples. To open MATLAB help, you
can type doc or go to Help ° Product Help. To directly open help about a function (for example sin), we would type

doc sin;

Getting Started
In our first example, we will create a simple program to multiply two numbers. MATLAB programs are called scripts
or also M-files because their extension is ‘.m’. To create a script named myfirstprogram.m, let us go to the command
window and type

edit myfirstprogram

MATLAB will open an editor window with a blank file name. Type the following code

a=4;
b=3;
c=a*b;
disp(c);

Save this file and run the code by entering the following in the command window

myfirstprogram

3
CHAPTER 1 N INTRODUCTION TO MATLAB

When you press enter, you get the following output

c=
12

Let us spend some time in understanding this simple program. We don’t need any sophisticated program
definitions or imports to run a simple program such as multiplication in MATLAB. In this program, we have defined
two variables a and b. To define/assign a variable, we simply need to type

variablename= variablevalue;

We then multiplied them to store the answer in c and displayed it using the disp command.
The semicolon used to terminate each line is not necessary. If the semicolon is omitted, MATLAB will also
display the value computed in the right-hand side of the statement. For example, typing

c=a*b;

will result in the computation of c without displaying the result, while typing

c=a*b

will result in the computation of c and also result in the display of the output in the command window. We can change
the value of any variable by reassigning its value. For example

c=7;

will change the value of c to 7.


The first question which comes to our mind concerns the type of a. Is it stored as a double or an integer?
First of all, all the variables stored in MATLAB are matrices. Secondly, all the numerical values are treated as double.
So 4 is a 1×1 double numerical matrix. So if we compute the division of a by b using

c=a/b

we will get 1.33. However, the thing to remember is that even if a is a double number, MATLAB still knows that it
can also be treated as an integer. This will be better understood in later chapters, when we try to index the matrix by
providing integer indices.

Creating a Matrix
To create a matrix, we enclose all the elements inside [ ]. For example, to create a row vector containing the six
elements 1 3 5 6 3 2, we can write

A= [1 3 5 6 3 2]

or

A=[1,3,5,6,3,2]

4
CHAPTER 1 N INTRODUCTION TO MATLAB

The comma or space here separates the elements into a single row and instructs MATLAB to construct a new
column for the next element. Similarly we can construct a column vector with the same elements by typing

A=[1;3;5;6;3;2]

Here, each semicolon tells MATLAB to start a new row for the next element. Both comma and semicolon
operators can also be used to join two matrices, for example

A=[4;5];
C=[2;A];

or

C=[2; [4;5]]

We can also mix these two operators to form a rectangular matrix.

A=[2 3 ; 4 5 ; 6 7]
B=[[2;4;6] , [3 ;5;7]]
C=[2 [3] ; [4;6] [5 7]]

All three of the above operations give the same 3×2 matrix. There is another operator ‘:’, known as the colon
operator, which means ‘to’. For example, to create a matrix with elements from 0 to 100 with unit difference,
we can type

A=[0:100];

To create a matrix with elements from 0 to 2p with step 0.01, we type

t=[0:.01:2*pi]

which can be interpreted as ‘from 0 to 2*pi with step .01’. Remember that pi is a pre-defined constant in MATLAB.
Now you can write these commands in the editor window and save/run it as an M-file. But you can also type
these commands directly into the command window. As we press enter after each command, that command will be
executed and the result will be the same as if it were executed as a script in the editor window. The benefit of writing
the commands in a script file is that it can be saved for future use, and it can be transferred among devices. However,
the command window can be used to test or view variables quickly. There are some cases where we want to run a
small command over some variables and we know that we will never use this command in the near future. In those
cases, an M-file is not needed and the command window can be used instead.

Functions
A function is a simple set of instructions which accepts some inputs and returns outputs. There are a wide range of
inbuilt functions in MATLAB for different application and they can be called anywhere with proper inputs. A function
call generally has the following syntax

[output1 output2]= functionname (input1, input2)

5
CHAPTER 1 N INTRODUCTION TO MATLAB

Consider the function sin which takes a vector and computes the sine of each of its elements, returning a vector
consisting of the values in the same order as the input. To view the syntax of the sin function we can type:

help sin

which displays a short description of the sin function and its syntax with some examples.

Sin:
Sine of argument in radians
Syntax
Y = sin(X)
Description
Y = sin(X) returns the circular sine of the elements of X. The sin function operates element-wise on
arrays. The function's domains and ranges include complex values. All angles are in radians.

After reading this, we can easily guess the format of the sin function. Now we can use this function as follows:

x=0:.01:2*pi;
y=sin(x);

Similarly, there is a wide range of functions such as log, exp, etc., which can be found at http://www.mathworks.com/
help/matlab/functionlist.html. We will encounter many of these functions as we go. Two of the most interesting
features of MATLAB are that these functions have very intuitive names and syntax, and their syntax can be easily
found just by going to MATLAB help.
In MATLAB, we can also define our own functions. Suppose we want to define a function myfun which computes
y=log(x)*sin(x/4) given the input x. We first create an M-file by typing

edit myfun

and then we type the following

function y= myfun(x)
y=log(x)*sin(x/4);

saving it to a file. Such a file is called a function file and has the same extension .m as a script. The first word of the first
line of this code tells MATLAB that it is a function file. Everything before the equals sign tells MATLAB what variables
to output and the word immediately after the equals sign is the function name by which MATLAB remembers this
function. This name should match the name of the file. The name is followed by a list of all the input parameters inside
parentheses. The rest of the code contains instructions to compute output variables from input variables.
To call this function, we write

x1 = 5
y=myfun(x1);

in any script, function or command window. Similarly, we can define a multiple input and output functions as

function [z p]= myfun(x,y)


z=log(x)*sin(y/4);
p=exp(x)*cos(z/4);

and this function can be called by

[a1 b1]=myfun(x,2);

6
CHAPTER 1 N INTRODUCTION TO MATLAB

If a function has no inputs, you can call this function by

out=myfunction()

or

out=myfunction

The Difference Between Functions and Scripts


Functions and scripts are both M-files, but there are a few differences between them. As we saw, the first line defines
whether the M-file is a function or a script. A function has a particular set of inputs and outputs, while a script doesn’t.
A script can use all the variables created in the MATLAB workspace, but a function can only use the variables specially
passed to it. After the execution is over, a script returns all the variables to the workspace while a function only returns
the variables listed as outputs and deletes the rest of the variables. Scripts use the same copy of a variable in the MATLAB
workspace and modifying any variable in any script will affect the original copy in the workspace while a function creates
a new copy of all the variables when they are called and any modification to these variables doesn’t affect the original
variables. In other words, when a function is called from a workspace, the function call creates a new workspace, copies
variables to it, computes outputs and returns these variables to the calling workspace, deleting its own workspace.
You can also call a script from a function. In that case, the script will use the calling function’s workspace and the
variables created by this script call will also get deleted when the calling function finishes its execution.
As we saw, scripts, variables and functions (with no input) are called in the same way. For example, to display a
variable finalsum we write

finalsum

and to run a script named scrfinal we write

scrfinal

Similarly, to multiply the variable finalsum by 2, we write

x=2*finalsum;

and if there is a function named mypiconst defined as

function x=mypiconst
x=3.14;

we can multiply the output of this function by 2 by writing

x=2*mypiconst;

What if there is a variable named finalsum and a script file with name finalsum.m? How does MATLAB know
which one to use? The answer is that MATLAB first searches for the variable in its workspace and if it cannot find any
matching variable then it searches for scripts or functions in the current directory. In other words, a variable shadows
a script or function with the same name. This is also true for inbuilt functions. For example, we saw that sin is used to
compute the sine of a variable. Let us define our own variable sin and then try to call the sin function

sin=4;
d=sin*3
y=sin(3);

7
CHAPTER 1 N INTRODUCTION TO MATLAB

We will get d=12, but the next line will cause an error because sin is treated as a variable here and it is trying to
access the third element of the sin matrix. Here, ( . ) denotes indexing, which we will learn more about later. To see
this explicitly, we can ask MATLAB about any variable name/function to determine which version MATLAB is using
by typing

which sin

to which MATLAB displays

sin is variable.

To use the function sin again, we need to delete the sin variable first by typing

clear sin

To clear all the variables, we type

clear all

Now typing which sin results in

sin is inbuilt function.

This is crucial and we need to remember it, otherwise we would constantly run into errors or unexpected
outputs. For example, in the above code, if we use

sin=4;
d=sin*3
y=sin(1);

it will run without error because y will be assigned the first element of the sin variable, which is 4. So instead
of getting 0.8414, you will get y=4, and all subsequent computations will be incorrect, possibly without us realizing
the mistake.

Special Matrices
We can also create some special matrices via inbuilt functions. For example, to create matrix of size 5×6 all entries of
which are ones, we can write

A=ones(5,6);

Similarly zeros will create an all zero matrix, eye will create an identity matrix and rand will create a matrix whose
entries are random values between 0 and 1.

8
CHAPTER 1 N INTRODUCTION TO MATLAB

Other Variable Types


We saw that MATLAB creates variables of type matrix. Until now, we have only seen variables containing numerical
matrix values. In this section, we will meet a few other types of variables that MATLAB implements.

Character Variables
A character variable is a string containing characters. Remember that a single character is just a 1×1 character matrix.
To define a string we write

A='strval';

which is equivalent to

A=['s' 't' 'r' 'v' 'a' 'l'];

To define multiline strings, we need to define each row with the same number of columns by including spaces.
For example

A=['john';'joe'];

Cells
When a collection contains elements of different types, they can be represented using a cell array. A multiline string
can be better represented using cells since different elements in a cell can have a different number of columns, hence
strings with different lengths.

A={'name', 12};
A={'john','joe'};

Logical Variables
Logical or boolean variables can have only two values, true (1) or false (0). To create a logical matrix, we write

A=[true, false, true];

or

A=logical([1,0,1]);

Structures
A structure has many variables attached to it, indexed by fields. For example, a student is attached to variables
declaring his name, class and cgpa. To construct a student structure, we write

student.name='John';
student.class=10;
student.cgpa=3.5;

9
CHAPTER 1 N INTRODUCTION TO MATLAB

which results in a structure matrix of size 1×1. To create a second element of the above matrix, we can write

student(2).name='Joe';
student(2).class=9;
student(2).cgpa=3.7;

Saving/Loading Variables
Since MATLAB deletes all its variables when it is closed, you can save all the variables in a data file for the next session
by executing the following

save filename

Similarly we can load all the variables using

load filename

Plots
MATLAB also provides easy and simple plotting functions. To plot data, you need two vectors of the same size, one
for the x axis and the other for the y axis. When we call plot with these two vectors, MATLAB will create a pair (x,y) by
taking corresponding elements from these two vectors, plotting them on a Cartesian plane and connecting them by
straight lines.
The following example shows how to plot a rectangle in MATLAB (see Figure 1-2)

x=[1 0 -1 0 1];
y=[0 1 0 -1 0];
plot(x,y);

Figure 1-2. Plotting a rectangle

10
CHAPTER 1 N INTRODUCTION TO MATLAB

If the x values are very close to one another, the plot will look like a continuous plot (See Figure 1-3)

t=0:.01:2*pi;
y=sin(t);
plot(t,y);

Figure 1-3. Plotting a continuous function

In later sections we will see other plotting functions in greater detail.

11
CHAPTER 2

Matrix Representation, Operations


and Vectorization

Recall that MATLAB is an abbreviation for Matrix Laboratory. Everything in MATLAB is a matrix, be it a scalar,
variable or an image. The primary motivation behind building an entire piece of software for matrices was the fact
that matrices are very important in engineering. Almost everyone has seen matrices in mathematics, where they
are used for linear transformations, but matrices are also used in a wide range of applications in engineering where
they represent a variety of different notions. In this section, we will see different representations of matrices, their
applications, and learn different operations on them. Another important aspect is the trick known as vectorization.
Since we will be dealing with big matrices, we will see that it is important to avoid loops over matrices using this trick.

Matrix Representation
In this section, we'll look at ways to represent matrices.

Conventional Sense: Matrices


Matrices are widely used in mathematics, especially in Linear Algebra. Recall that a matrix is a two-dimensional set of
elements. The most common usage is to represent a transformation on some space. For example, consider a 2D vector

ª2 º
x «3» .
¬ ¼

Let us take the rotation matrix A as

ª 0 1º
A « ».
¬ 1 0 ¼

Now define y as

ª 0 1 º ª2 º ª 3 º
y Ax « 1 0 » « 3 » « 2 »
¬ ¼¬ ¼ ¬ ¼

which is the 90o rotated version of x.

13
CHAPTER 2 N MATRIX REPRESENTATION, OPERATIONS AND VECTORIZATION

Data Sense: Arrays


There is a whole new meaning of matrices in engineering where they can also be used to represent data. Such
matrices are called arrays. For example, consider an input signal to an electric motor shown in Figure 2-1.

Figure 2-1. Input signal to an electric motor

The same signal can be represented as the following matrix:

x=[0.0048 0.21 0.41 0.597 0.76 0.89 1.00 1.059 1.085 1.07 1.01 0.92 0.80 0.65 0.48 0.29 0.10
-0.0773565 -0.25 -0.41 -0.55];

An image is another example of such data representation. A color image is a three dimensional matrix. For
example, the small 4×4 pixel image in Figure 2-2 can be represented as the following matrix

A=[1 2 0 2;3 2 1 3;3 2 1 0;1 3 2 2];

where 0 1 2 3 denotes black, red, green and blue respectively.

Figure 2-2. A sample image

A set of points representing a plot is another example of such a representation.

14
CHAPTER 2 N MATRIX REPRESENTATION, OPERATIONS AND VECTORIZATION

Model Representation
In engineering, we often model a physical system as a mathematical model where each such model consists of some
parameters and design equations. These parameters can also be represented as matrices. The simplest example is a
polynomial. Consider p( x ) x 3  2 x 2  6 x  4. We can represent this as the matrix p=[3 -2 6 4]. Other examples are
neural networks, transfer functions etc. Consider the transfer function
s3
F s
s  3s  2
2

which is a ratio of two polynomials, so we can represent it by two vectors n1=[1 3] and d=[1 3 2]. How we are going to
use these vectors for model computations (for example, step response) is something we need to remember. Note that
all these representations look the same. Since they are represented as matrices, there is no distinction between them
from the perspective of MATLAB. When storing some p, MATLAB doesn’t make any distinction as to whether p denotes
a polynomial or a neural network’s bias value. The programmer needs to remember what a vector/matrix represents.

Operations
MATLAB provides a wide range of operations and functions you can perform over vectors. In MATLAB, you can
represent each operator as a function too. Therefore, in this discussion, we will be using functions and operators
interchangeably. Since a matrix can represent various different notions, as we have seen in the previous section, there
are different functions/operators suited for different representations, sometimes with almost the same name and/or
purpose. This section will describe these operations and their important differences.

Matrix Operations
The operators that are performed over matrices in their conventional mathematical sense and which follow the
laws of linear algebra are known as matrix operators. For example, to invert a transformation, we can use the invert
operator or pinv function.
If y Ax then x A * y , where A* is the Moore-Penrose inverse, which can be computed as follows:

x=[2 3 5];
A=[1 0 -1;1 1 0;1 2 3];
y=Ax;
x=pinv(A)*y

Suppose we apply a transformation operator twice:

y=A*A*x;

This is equivalent to computing the square of a matrix via the matrix power operator

Asq=A^2

and computing y by

y=Asq*x

15
CHAPTER 2 N MATRIX REPRESENTATION, OPERATIONS AND VECTORIZATION

Similarly you can compute the square root either by calling the function

y=sqrtm(A)*x

or via the power operator as

y=A^0.5*x

We can also compute the product of two matrices using the function mtimes or the * operator

B=mtimes(A,C);
B=A*C;

Both of the above lines return the same results. Remember that this is matrix multiplication according to the rules
of linear algebra, so the number of columns in A should match the number of rows in C, otherwise the multiplication
is not defined and MATLAB will return an error.
Note the letter m in sqrtm and mtimes, which denotes ‘matrix’. Since the square root and multiplication
operations are defined differently for different representations of matrices, the matrix versions are sqrtm and mtimes.
The former computes the matrix square root in the convention mathematical sense. Other important operations are +,
\ (mldivide), / (mrdivide), '(ctranspose), ^ (mpower). Readers can refer to the MATLAB documentation for a full list
of operations at http://www.mathworks.com/help/matlab/matlab_prog/array-vs-matrix-operations.html. There
are also some operators which can only be used in this representation, such as eigenvalue and determinant, which
can be computed using the following commands

y=eig(A);
z=det(A);

Dot (array) Operators


Recall that matrices can also represent data and each element of such a matrix denotes a data value (e.g. time
sampled data point, field value at a spatial point). When we perform an operation on such a matrix, it means that we
are performing the same operation at each element independently. Such an elementwise operation is known as a dot
operation or array operation and this type of operation must be used for data matrices. For example, consider a matrix
V containing voltage values at time [0:0.1:1] given as

V=[0 .19 .38 .56 .71 .84 .93 .98 .99 .97 .90];

and the matrix I representing current values at the same time instances, given as

I=[.29 .47 .64 .78 .89 .96 .99 .99 .94 .86 .74];

Now we can compute the power values at each time instant by

P=V.*I

The .* operator is known as the times operator and is used to multiply two matrices elementwise. Compare
the times operator with the mtimes operator discussed in the previous section. The letter ‘m’ is used to differentiate
between the two types of multiplication. Here, the times operator is only valid if either the two matrices have the same
size or if at least one of them is a scalar. Note that if one of the matrices is a scalar, the times and mtimes operators
result in the same operation.

16
Discovering Diverse Content Through
Random Scribd Documents
"Now I can keep my place, the children will not miss me. Thank you,
Uncle Wiggily," mewed Puss.
"Pray do not mention it," said the bunny. "I am glad I don't have to
carry two pairs of boots."
So Mr. Longears hopped on a little farther, and soon he heard some
tiny voices saying:

"Oh, Mother dear! Look here! Look here!


Our mittens we have lost!"

"Ho! I should know who they are!" said the bunny. "Those must be
the three kittens!"
And, surely enough, they were, as the bunny saw a moment later,
when he turned around the corner of a mulberry tree. There were
three little pussy kittens, holding up their paws for their mother to
see, and there wasn't a single mitten on any one of the paws! What
do you think of that?

"What, lost your mittens! You careless kittens!


Now you can't have any pie!"

Thus sang the mother cat. And when the three little kittens, who
had lost their mittens, began to cry, Uncle Wiggily felt so sorry for
them that he stepped up and said:
"Excuse me, Mrs. Cat. But I have a lot of red yarn I bought for Nurse
Jane to knit mittens for Sammie and Susie Littletail. There is more
than Miss Fuzzy Wuzzy needs, I'm sure, so I shall give you some to
knit mittens for your pussies."
"Oh, how kind you are!" mewed the mother cat, as Uncle Wiggily
gave her three balls of red yarn, still leaving plenty for the rabbit
children's mittens. "Now you may have some pie, and I'll give Uncle
Wiggily a piece, too," said the cat mother to her kittens.
"You are very kind," remarked Mr. Longears. "But I must hop on with
the needle and thread, and the piece of white flannel Nurse Jane is
going to use to make herself a new petticoat."
So on hopped the bunny, while the mother cat sat down to knit
some new mittens for her kittens. And Uncle Wiggily had not gone
very far before, all of a sudden, he heard another sad mewing sound
and a voice said:
"Dear me! The hole goes all the way through! I shall never be able
to go to see Old Mother Hubbard this way! Oh, what an accident!"
"That sounds like more trouble," thought Uncle Wiggily, and, looking
over the top of a stone wall, he saw a pussy cat lady sitting on a
stump, sadly looking at her skirt.
"What is the matter?" asked Mr. Longears.
"Oh! How you surprised me!" mewed the cat lady. "But here is the
trouble. I'm Pussy Cat Mole. I jumped over a coal, and in my best
petticoat burned a great hole!" and she showed the edge of her
petticoat where, surely enough, a hole was burned through.
"And I ought to be at Mother Hubbard's now, to go with her to the
movies," said Pussy Cat Mole. "But, alas, I can not go!"
"Oh, yes, you can!" said Uncle Wiggily.
"Not with this big burned hole in my petticoat!" mewed the cat.
"Ah, but you shall sew on a patch," said the bunny. "I have here
needle and thread, and some white flannel. Can't you mend your
best petticoat with all those?"
"Indeed I can," mewed Pussy Cat Mole. "Thank you, so much!"
Uncle Wiggily gave her a needle and thread, and with her claws Miss
Mole tore off a piece of white flannel, for there was more than Nurse
Jane needed. She sewed the patch neatly on, and then, with her
petticoat nicely mended, Pussy Cat Mole went on to Mother
Hubbard's.
"Ah, how delightful it is to be helpful," said Uncle Wiggily, as he
hopped back to his bungalow. And he was very glad he had met the
three cats, one after another. For a little later that day the bad
Woozie Wolf chased the bunny.
But the mother of the three kittens, after she had knit their mittens,
tickled the wolf with her knitting needles. Puss with the boots,
stepped on the wolf's tail so hard that he cried "Ouch!" And Pussy
Cat Mole ran at the wolf with a piece of red stone, which she
pretended was a red hot coal that in her best petticoat had burned a
great hole.
"I'll burn you! I'll burn you!" she mewed at the wolf.
"Then this is no place for me!" he howled, and away he ran, not
hurting the bunny at all. And how the bunny gentleman and the
three cats laughed!
So if the elephant from the Noah's Ark doesn't drop a cold penny
down the back of the gold fish and make it sneeze, the next story is
going to be about Uncle Wiggily and the lost boy.
STORY IX
UNCLE WIGGILY AND THE LOST BOY

"There goes that boy out again, flying his kite," said Nurse Jane
Fuzzy Wuzzy, as she looked from the window of the hollow stump
bungalow one morning.
"What boy?" Uncle Wiggily wanted to know.
"The new boy who has just moved into the red brick house,"
answered the muskrat lady housekeeper. "I hope he isn't a bad boy,
who will chase you, Uncle Wiggily, and come to the forest to play
tricks on Sammie and Susie Littletail, and the other animal boys and
girls."
"Oh, he doesn't look like that kind of a boy," said the bunny rabbit
gentleman, as he sat down to eat his breakfast of carrot pancakes
with turnip maple sugar gravy sprinkled down the middle. "But I'll be
careful until I get to know him better."
Uncle Wiggily's hollow stump bungalow had lately been rebuilt near
the edge of a wood, and, just beyond the thicket of trees and tangle
of bushes was a small town, where lived many boys and girls.
Only a few of these boys and girls knew about the bunny rabbit
gentleman, and his muskrat lady nurse, and those who did were
kind to Uncle Wiggily, because the rabbit gentleman had been kind
to them, doing them many favors.
But now that a new boy had moved into the red brick house, Uncle
Wiggily felt that he must not hop around in too lively a fashion, until
he found out whether the boy was bad or good. For there are some
bad boys, you know.
"He seems quiet enough," said Nurse Jane, as she spread some
lettuce marmalade on a slice of bread for Uncle Wiggily. "He sits
there flying his kite. I guess it will be safe for you to go to the store
for me, Wiggy."
"What do you want from the store?" asked the bunny gentleman, as
he took his tall, silk hat down off the piano. Sometimes he went to
the store quite dressed up. At other times he would put on an old
cap and overalls, just as he came from the garden.
"I want another ball of red yarn," Nurse Jane answered. "I did not
have quite enough to knit the mittens for Sammie and Susie, the
rabbit children."
"I suppose that's because I gave some of the yarn to the three little
kittens who lost their mittens," said the bunny, twinkling his pink
nose upside down, to make sure it would not fall off as he hopped
along.
"Well, that's one of the reasons," Nurse Jane answered. "But I'm
glad you helped the little kittens. You can easily get me another ball
of yarn."
"Of course," Uncle Wiggily agreed, and soon he was hopping over
the fields and through the woods, on his way to the store. Not one
of the stores where the boys and girls bought their toys and
lollypops, but a special animal store, kept by a Monkey Doodle
gentleman.
And as Uncle Wiggily hopped along under the bushes, near the
house of the Kite Boy, the bunny heard the boy's mother say:
"Don't go away and get lost, Buddie!"
"No'm, I won't!" promised the boy, as he held his kite string in his
hand and watched his toy fly high in the air.
Uncle Wiggily stopped for a moment, underneath a big burdock
plant, and looked at Buddie, which was the boy's pet name. Buddie
could not see the rabbit gentleman. If he had, Buddie would have
been much surprised to notice a bunny with glasses and a tall silk
hat.
The wind blew the kite higher into the air, and Uncle Wiggily thought
of the many times he had helped Johnnie and Billie Bushytail, the
squirrels, fly their kites, and how he had, more than once, made
kites for Jackie and Peetie Bow Wow, the puppy dog boys.
Then the bunny gentleman hopped on to the store to get the ball of
red yarn for Nurse Jane. He stayed some little time, Mr. Longears
did, for he met Grandfather Goosey Gander, and talked to the old
gentleman duck about rheumatism, and what to do when you
sneezed too much.
But finally Uncle Wiggily started back for his hollow stump bungalow,
and soon he was in the middle of the wood, about half way home.
And all of a sudden the bunny gentleman heard a crying voice
saying:
"Oh, dear! Oh, dear! I don't know where my home is! I'm lost! Oh,
dear! I'm lost!"
Mr. Longears peered through the bushes, and there he saw the boy
from the red brick house, who held in his hand a broken kite.
"Ah, I see what has happened!" said the bunny. "His kite broke loose
from the string. Forgetting what he promised his mother, about not
going away, the boy ran after his kite, over into the woods, and now
he is lost. I wonder if I can help him find his way home?"
Uncle Wiggily did not show himself yet. Hiding behind the bushes,
the bunny followed the lost boy as he wandered about among the
trees, not knowing which way to go.
"Oh, where is my house?" said the boy over and over again. "Why
can't I find it?"
Then a mournful voice cried:
"Woo! Woo! Woo!"
"Oh, dear! What's that?" exclaimed the lost boy, suddenly stopping.
"It's only an owl bird," said Uncle Wiggily to himself. He wished he
might speak to the boy, and tell him this, but though the bunny
could understand boy-talk, the boy couldn't understand rabbit
language.
The Kite Boy went on a little farther, and then he heard a rustling in
the dried leaves.
"Oh-o-o-o!" gasped the lost boy. "Maybe that's a snake!"
"Nonsense!" laughed Uncle Wiggily to himself. "It is only a brown
thrush bird, scattering the leaves to look for something to eat. And,
even if it were a snake it wouldn't hurt the boy. I wish I might tell
him so."
The boy wandered along a little farther, and suddenly there boomed
out through the forest a sound of:
"Ga-rump! Ga-roomp! Ga-Zing!"
"Oh, maybe that's a giant!" cried the boy, dropping his broken kite.
"Ha! Ha!" laughed Uncle Wiggily. "That's only Grandpa Croaker, the
big bull frog who tells such funny stories to Bully and Bawly No-Tail,
the frog boys! How Grandpa Croaker will laugh when I tell him the
lost boy thought him a giant! But I must help this boy out of the
woods, or his mother will be worried."
"Let me see, how can I do it without letting him see me? Ha! I have
it. This ball of red yarn. I'll hop to the edge of the wood, near his
house, and fasten one end of the red yarn to a tree there. Then I'll
come back, unwinding the ball on the way, and when I get to the
boy, I'll toss him what is left of the ball. Then all he'll have to do will
be to follow the red cord right to his house."
No sooner said than done! Uncle Wiggily knew his way through the
forest, even in the dark, and he soon reached the edge of the wood
and saw the boy's red brick house.
Then, tying one end of the red yarn to the bush near where the boy
had been sitting to fly his kite, Uncle Wiggily turned back, unrolling
the ball as he hopped along. He soon came to the lost boy again,
and the poor little chap was crying harder than ever.
Over the bush and at the feet of the boy, the bunny tossed the little
ball of yarn that remained.
"Oh, what's that?" cried Buddie, almost ready to jump out of his
skin. But when he saw the little red ball, and the red string
stretching off through the trees, he was no longer afraid.
"Oh, maybe this is a fairy string, and will lead me home!" he joyfully
cried, as he began to follow it. And, though we know it wasn't a fairy
string, still it was just as good, for it led the boy home, as he
followed the yarn, winding up the ball as he walked along. And, oh,
how fast he ran when he came within sight of his house, crying, as
he dropped the ball:
"Here I am, Mother! Here I am. I'm not lost any more!"
"Well, I'm glad of that," Mother answered. "You shouldn't have gone
into the woods. I was just coming to look for you."
"Well," whispered Uncle Wiggily to himself, "I'm glad I could be of
some help in this world." Then the rabbit, who had followed the lost
boy until Buddie found his home, wound up the red yarn again, and
took it to Nurse Jane.
"My! That was quite an adventure," said the muskrat lady when the
bunny gentleman told her about it. And if the boiled egg doesn't try
to go sailing in the gravy boat, and splash condensed milk on the
bread-knife, I'll tell you on the page after this about Uncle Wiggily
and Stubby Toes.
STORY X
UNCLE WIGGILY AND STUBBY TOES

There are some children who are always stubbing their toes and
falling down. That was what happened, far too often, to the little
boy in this story. And I am going to tell you how Uncle Wiggily
helped cure him.
Perhaps you may think it strange that an old rabbit gentleman, with
a pink, twinkling nose and a tall, silk hat could cure a boy of
stubbing his toes. But this only goes to show that you never can tell
what is going to happen in this world.
So we shall start by saying that, once upon a time, there was a boy
who slipped and stumbled so often that he was called "Stubby Toes."
Stubby Toes was not a very big boy. In fact, one of the reasons he
stubbed his toe so often (first the big toe of one foot, and then the
big toe of the other foot), the reason, I say, was because he was so
small. He had not yet grown up so that he knew how to step over
things that lay in his path, causing him to stumble.
Why, sometimes that boy would stumble over a pin on the sidewalk.
And again I have known him to trip and almost fall because he saw,
in his way, a leaf from a tree.
"Upsi-daisey!" his sister would cry as she caught him by the hand, so
he would not fall. "Upsi-daisey, Stubby Toes!"
It was Sister who really gave Stubby Toes his name, but she was
only in fun, of course.
Well, one day when Uncle Wiggily had started out of his hollow
stump bungalow to look for an adventure, Sister took her little
brother Stubby Toes for a walk. And, as it happened, the path taken
by Sister and Stubby Toes stretched along through the woodland
where the bunny gentleman lived.
"I think I'll go see Baby Bunty to-day," said Uncle Wiggily to himself,
as he hopped along, twinkling his pink nose in the sunshine. "I have
a little touch of the rheumatism, and Baby Bunty is so lively, always
playing tag, or something like that in the way of games, that she'll
make me spry, and chase the pain away."
But as the bunny gentleman came near the place where the little
boy and his sister were walking, all of a sudden Stubby Toes tripped
over a little stone, about as large as the end of your lollypop stick,
and—down he almost fell!
"Upsi-daisey!" cried Sister as she pulled Brother to his feet. "Upsi-
daisey!"
"Oh, ho! Boo hoo! I—I stubbed my toe!" cried the little boy.
"Of course you did!" said Sister, laughing.
I think I forgot to tell you that Stubby Toes often cried when he
slipped this way. Yes, almost every time he cried, and Sister wished
he wouldn't, and so did Mother.
"Boo hoo! Boo hoo!" the boy wailed. "I bunked myself!"
Sister laughed and recited this little verse, which is a good one to
sing whenever anything happens. It is a verse I read once, many
years ago.

"Oh, fie,
Do not cry,
If you stub your toe.
Say 'Oh!'
And let it go.
Be a man,
If you can,
And do not cry!"
After Sister had sung this for Brother, she wiped away his tears,
which just started to trickle down his cheeks, and they walked on
again.
"This is a good little girl," said Uncle Wiggily to himself, for, hidden in
the bushes he had heard and seen all that went on. "I wish I could
teach Stubby Toes not to stumble so much. I wonder how I can? I'll
ask Baby Bunty about it."
So Uncle Wiggily hopped on to Baby Bunty's bungalow, and,
meanwhile Brother and Sister walked through the woods.
Well, I wish you could have seen what happened to Stubby Toes!
But, no! Perhaps, on second thought, it is better that you did not.
But, oh! So many times as he almost fell!
He tripped over a little baby angle worm, who was crawling to the
store to get a loaf of cake for his mother. And next Stubby Toes
almost landed on his nose, because the shadow of a bird flitted
across his path.
"Oh, Stubby Toes!" cried Sister, as she kept him from falling on his
face. "Will you ever learn to walk without stumbling?"
"Boo hoo!" was all that Stubby Toes answered, for, just then he
tripped over a blade of grass, and this time he fell down all the way.
Only he happened to land on some soft, green moss, so he was not
much hurt, I'm glad to say.
"This is too bad!" Uncle Wiggily said to himself, for he had heard and
seen it all. "I must get Baby Bunty to teach this little chap how to
walk more carefully."
It was not far to the home of Baby Bunty. That little rabbit girl was
out skipping her rope in front of her house.
"Tag, Uncle Wiggily! You're it!" she cried, as soon as she saw the
bunny gentleman.
"Tut! Tut! We have no time for a game now," said Mr. Longears. "I
want you to come with me, Baby Bunty, and teach Stubby Toes a
lesson," and he told about the little boy.
"Oh, I see what you mean," said Baby Bunty. "You want me to hop
along in front of him, and show him how not to stub his toe."
"That's it!" said Uncle Wiggily. "Stubby Toes and Sister are kind to
animals and will not harm us."
So, a little later, Uncle Wiggily and Baby Bunty were walking along
the woodland path just ahead of the little boy and his sister.
"Now, Baby Bunty," said Mr. Longears, "show this boy how nicely you
can hop along, even if there are sticks and stones on the path."
Away skipped the little rabbit girl. She came to a stone, but over it
she stepped as nicely as you please. She reached a stick, but she
gave a hop, and there she was on the other side! And she never
stubbed her toe once, because she was careful!
By this time the little boy and his sister had seen Uncle Wiggily and
Baby Bunty.
"Oh, look at the funny rabbits!" cried Stubby Toes. "I want to catch
'em!"
"No! No! Mustn't touch!" said Sister, and she reached out to catch
hold of Stubby Toes, but it was too late! He tripped his foot on a
dandelion blossom in the grass, and down he went!
"Boo hoo!" he cried.
"Oh, fie!" said Sister, singing the little verse again. "Look at the baby
rabbit! She doesn't stub her toes!"
And, surely enough, Baby Bunty, skipping along on the path in front
of Stubby Toes, never fell once. She skipped over pebbles and
stones, sticks and clumps of grass, and never once stepped on a
flower.
"See if you can't do that, Stubby Toes!" begged Sister.
And of course that boy didn't want a little baby rabbit girl to walk
better than he did. So he dried his tears, stood up straight and
began to walk more firmly, watching where he set down his feet.
He came to a big stone and—over it he stepped without stumbling.
He reached a stick—and, over that he put both feet without falling!
He passed a lump of dirt—and right over it he JUMPED—and he
didn't stub his toe once! What do you think of that?
"Oh, I'm not going to call you Stubby Toes any more!" laughed
Sister. "Now you have learned to walk as well as that baby rabbit."
Uncle Wiggily laughed so hard that his tall silk hat almost slipped
down over his pink, twinkling nose.
"I think we have done enough, Baby Bunty," he said, "Come on now,
and I'll buy you a carrot lollypop!"
Away hopped the bunnies, and back home went Sister and Brother
who was Stubby Toes no longer. Baby Bunty had taught him a good
lesson.
And if the jumping jack doesn't fall off his stick when he is trying to
play hop scotch with the bean bag, you shall next hear about Uncle
Wiggily's Christmas.
STORY XI
UNCLE WIGGILY'S CHRISTMAS

Down swirled the snow, its white flakes blown by the cold December
wind. From the North it came, this wind; and a bird—not a robin, for
they had long ago flown South—a bird went in the barn, and hid his
head under his wing, poor thing!
It was cold in the woods around Uncle Wiggily's hollow stump
bungalow, and the rabbit gentleman brought in stick after stick of
wood for Nurse Jane Fuzzy Wuzzy to pile on the blazing fire that
roared up the chimney.
Uncle Wiggily, having filled the wood box, took his cap, and his fur-
lined coat down from the rack.
"Dear me, Wiggy! You aren't going out on a day like this, are you?"
asked Nurse Jane.
"Yes," answered the bunny gentleman, "I am, if you please, Nurse
Jane. I promised Grandfather Goosey Gander I'd go down town
shopping with him. He wants to look through the five and ten cent
stores to see what they have for Christmas."
"Oh, well, if it's about Christmas, that's different," said the muskrat
lady. "But wrap yourself up well, for it is storming hard. I don't want
you to take cold."
"Nor do I want a cold," said Uncle Wiggily. "My pink nose gets very
red when I sneeze. I'll be careful, Nurse Jane."
Out into the snowy, blowy woods went Uncle Wiggily. He passed the
burrow-house where Sammie and Susie Littletail, the rabbit children,
lived. Susie was at the window and waved her paw to the bunny
gentleman.
"Only three more days until Christmas! Aren't you glad, Uncle
Wiggily?" called Susie.
"Indeed I am," answered Mr. Longears. "Very glad!"
Johnnie and Billie Bushytail, the squirrels, looked from the window of
their house. Johnnie held up a string of nuts that he was getting
ready to put on the Christmas tree.
"Billie and I are going to help Santa Claus!" chattered Johnnie.
"Good!" laughed Uncle Wiggily. "Santa Claus needs help!"
The bunny hopped along through the snow until he reached the
kennel of Jackie and Peetie Bow Wow, the puppy dog boys.
"We're popping corn!" barked Jackie. "Getting ready for Christmas!
That's why we can't be out!"
"Stay in the house and keep warm!" called Uncle Wiggily.
He hopped on a little farther until he met Mr. Gander, and the rabbit
gentleman and the goose grandpa made their way through the five
and ten, the three and four and the sixteen and seventeen cent
stores. Each place was piled full of Christmas presents for animal
boys and girls, and animal fathers and mothers were shopping
about, to tell Santa Claus what to bring to the different houses, you
know.
Uncle Wiggily saw some things he knew Nurse Jane would like, and
Grandpa Goosey bought some presents that had come directly from
the workshop of Santa Claus.
Then along came Mr. Whitewash, the Polar Bear gentleman.
"Ho! Ho!" roared Mr. Whitewash, in his jolly voice. "Come to my ice
cave, gentlemen, and have a cup of hot, melted icicles!"
"I'd like to, but I can't," said Uncle Wiggily. "Nurse Jane wanted me
to get her some spools of thread. I'll buy them and go back to my
bungalow."
"Then I'll go with you, Mr. Whitewash," quacked Grandpa Goosey,
and he waddled off with the bear gentleman, while Uncle Wiggily,
having bought the thread, hopped toward his bungalow.
The bunny uncle had not gone very far before he heard some
children talking behind a bush around which the snow was piled in a
high drift. Uncle Wiggily could hide behind this drift and hear what
was said.
"Is Santa Claus coming to your house?" asked one boy of another.
"I don't guess so," was the answer. "My father said our chimney was
so full of black soot that Santa Claus couldn't get down. He'd look
like a charcoal man if he did, I guess."
"It's the same way at our house," sighed the first boy. "Our chimney
is all stopped up. I guess there'll be no Christmas presents this year."
"My! That's too bad!" thought Uncle Wiggily to himself. "There ought
to be a Christmas for everyone, and a little thing like a soot-filled
chimney ought not to stand in the way. All the animal children whom
I know are going to get presents. I wish I could help these boys.
And they probably have sisters, also, who will get nothing for
Christmas. Too bad!"
Uncle Wiggily peered over the top of the snowbank. He saw the
boys, but they did not notice the rabbit, and Mr. Longears knew
where the boys lived. Their homes were in houses near the brick
one, where dwelt the lad who was once lost in the woods. Uncle
Wiggily unwound a ball of red yarn, if you will kindly remember, and
by following this the Kite Boy found his house.
"I wish I could help those boys who are not going to have any
Christmas," said the bunny gentleman to himself, as he hopped on
with Nurse Jane's spools of thread.
And just then, in the air overhead, he heard the sounds of:
"Caw! Caw! Caw!"
"Crows!" exclaimed Uncle Wiggily. "My friends the black crows! They
stay here all winter. Black crows—black—black—why, a chimney is
black inside, just as a crow is black outside! I'm beginning to think of
something! Yes, that's what I am!"
The rabbit's pink nose began twinkling very fast. It always did when
he was thinking, and now it was sparkling almost like a star on a
frosty night.
"Ha! I have it!" exclaimed Uncle Wiggily. "A crow can become no
blacker inside a sooty chimney than outside! If Santa Claus can't go
down a black chimney, why a crow can! I'll have these crows
pretend to be St. Nicholas!"
No sooner thought of than done! Uncle Wiggily put his paws to his
lips and sent out a shrill whistle, just as a policeman does when he
wants the automobiles to stop turning somersaults.
"Caw! Caw! Caw!" croaked the black crows high in the white, snowy
air. "Uncle Wiggily is calling us," said the head crow. "Caw! Caw!"
Down they flew, perching on the bare limbs of trees in the wood not
far from the bunny's hollow stump bungalow.
"How do you do, Crows!" greeted the rabbit. "I called you because I
want you to take a few Christmas presents to some boys who,
otherwise, will not get any. Their chimneys are choked with black
soot!"
"Black soot will not bother us," said the largest crow of all. "We don't
mind going down the blackest chimney in the world!"
"I thought you wouldn't," said Uncle Wiggily. "That's why I called
you. Now, of course, I know that the kind of presents that Santa
Claus will bring to the animal children will not all be such as real
boys and girls would like. But still there are some which may do."
"I can get willow whistles, made by Grandpa Lightfoot, the old
squirrel gentleman. I can get wooden puzzles gnawed from the
aspen tree by Grandpa Whackum, the beaver. Grandpa Goosey
Gander and I will gather the round, brown balls from the sycamore
tree, and the boys can use them for marbles."
"Those will be very nice presents, indeed," cawed a middle-sized
crow. "The boys ought to like them."
"And will you take the things down the black chimneys?" asked
Uncle Wiggily. "I'll give you some of Nurse Jane's thread so you may
easily carry the whistles, puzzles, wooden marbles and other
presents."
"We'll take them down the chimneys!" cawed the crows. "It matters
not to us how much black soot there is! It will not show on our black
wings."
So among his friends Uncle Wiggily gathered up bundles of
woodland presents. And in the dusk of Christmas eve the black
crows fluttered silently in from the forest, gathered up in their claws
the presents which the bunny had tied with thread, and away they
flapped, not only to the houses of the two boys, but also to the
homes of some girls, about whom Uncle Wiggily had heard. Their
chimneys, too, it seemed, were choked with soot.
But the crows could be made no blacker, not even if you dusted
them with charcoal, so they did not in the least mind fluttering down
the sooty chimneys. And so softly did they make their way, that not
a boy or girl heard them! As silently and as quietly as Santa Claus
himself went the crows!
All during Christmas eve they fluttered down the chimneys at the
homes of poor boys and girls, helping St. Nicholas, until all the
presents that Uncle Wiggily had gathered from his friends had been
put in place.
Then, throughout Woodland, in the homes of Sammie and Susie
Littletail the rabbits, of Johnnie and Billie Bushytail the squirrels,
Jackie and Peetie Bow Wow the dogs, Curly and Floppy Twistytail the
piggie boys—in all the homes of Woodland great changes took place.
Firefly lights began to glow on Christmas trees. Mysterious bundles
seemed to come from nowhere, and took their places under the
trees, in stockings and on chairs or mantels.
And then night came, and all was still, and quiet and dark—as dark
as the black crows or the soot in the chimneys.
But in the morning, when the stars had faded, and the moon was
pale, the glorious sun came up and made the snow sparkle like ten
million billion diamonds.
"Merry Christmas, Uncle Wiggily!" called Nurse Jane. "See what
Santa Claus brought me."
"Merry Christmas, Nurse Jane!" answered the bunny. "And what a
fine lot of presents St. Nicholas left for me! See them!"
"Oh, isn't he a great old chap!" laughed Nurse Jane, as she smelled
a bottle of perfume.
And all over the land voices could be heard saying:
"Merry Christmas! Merry Christmas!"
Near the hearth in the homes of some boys and girls who had not
gone to bed with happy thoughts of the morrow, were some
delightful presents. How they opened their eyes and stared—these
boys and girls who had expected no Christmas.
"Why! Why!" exclaimed one of the two lads whom Uncle Wiggily had
heard talking near the snowbank. "How in the world did Santa Claus
get down our black chimney?"
But, of course, they knew nothing of Uncle Wiggily and the crows.
And please don't you tell them.
So all over, in the Land of Boys and Girls, as well as in the Snow
Forest of the Animal Folk, there echoed the happy calls of:
"Merry Christmas! Merry Christmas!" Once again there was joy in the
land.
And if the sunflower doesn't shine in the face of the clock, and make
its hands go whizzing around backward, I shall take pleasure, next,
in telling you about Uncle Wiggily's Fourth of July.
STORY XII
UNCLE WIGGILY'S FOURTH OF JULY

"You must be extra careful to-morrow, Uncle Wiggily," said Nurse Jane
Fuzzy Wuzzy to the bunny rabbit gentleman one morning, as he stood
on the steps of his hollow stump bungalow.
"Why be careful to-morrow, more than on any other day in the year?"
asked Mr. Longears. "Is it going to rain or snow?"
"Whoever heard of snow on the Fourth of July?" inquired the muskrat
lady housekeeper, as she fastened a fluffy brush to the end of her tail,
for she was presently going in the house to dust the furniture.
"Oh, so to-morrow is the Fourth of July!" exclaimed the bunny. "I had
forgotten all about it. Yes, indeed, I must be careful! I am living near
the real children, now, and some of them might think it fun to explode
a torpedo under my pink, twinkling nose, or try to fasten a fire-cracker
to my little tail."
"That's what I was thinking of," went on Nurse Jane. For Uncle
Wiggily's bungalow, while still in the woods, was near to the homes of
some boys and girls. And though only one boy, so far, had been bad
to the bunny (and this boy soon turned good), there was no telling
what might happen.
So as Uncle Wiggily hopped along the forest path, he took care not to
get too far away from the bushes, behind and under which he could
hide. For sometimes boys and girls came to the forest, and once a
Kite Boy was lost, and the bunny helped him find his way home, you
may remember.
"Hello, Uncle Wiggily!" suddenly called a voice, and Mr. Longears
quickly jumped around, thinking it might be a real boy or girl. But it
was only Neddie Stubtail, the little boy bear.
"I've been buying my fire-crackers," said Neddie to his uncle, the
bunny. "I'm going to have lots of fun Fourth of July," and he showed
Mr. Longears a bundle of dry sticks, painted red, white and blue like
the bunny's rheumatism crutch.
You must know that in Animal Land the boys and girls have the same
sort of fun you children do on holidays, but in a different manner.
Instead of real fire-crackers, that have to be set off with a match, or
piece of punk, with sparks that, perhaps, burn you, the animal
children get some dried sticks. These they break, with loud, cracking
sounds, but without any fire. And they have lots of fun. After the
sticks are broken they can be put in the stove to boil the tea kettle.
"Did you get your sister, Beckie, any Fourth of July things?" asked
Uncle Wiggily of the boy bear.
"Oh, yes, I got her some little stick crackers," answered Neddie.
"That's good!" spoke Mr. Longears. Then he went on through the
woods, meeting Toddle and Noodle Flat-Tail the beaver boys, Joie,
Tommie and Kittie Kat the kittens, Nannie and Billie Wagtail the goats,
and many other animal boys and girls. All of them called:
"Hello, Uncle Wiggily! Happy Fourth of July!"
And the bunny answered back:
"Thank you! I wish you the same!"
Thus hopping through the woods, meeting the animal children, and
learning of the fun they were to have next day, the bunny rabbit
gentleman at length came to the end of the forest. A little farther on
were the houses and homes of real boys and girls, some of whom had
been helped by Mr. Longears.
"I think this is as far as I had better go, seeing it's so close to the
Fourth of July," thought Uncle Wiggily. "If the real children are
anything like those of my animal friends who live in the woods, they'll
be shooting off their crackers and torpedoes ahead of time."
And, just as he said that, Uncle Wiggily heard a loud:
"Bang! Bang!"
The bunny jumped to one side, and hid under the broad leaf of a
burdock plant. Then he laughed.
"I thought that was a hunter-man's gun," whispered Uncle Wiggily.
"But I guess it was some boy setting off a fire-cracker. I need not
have been afraid."
He was just going to hop along a little farther, before turning back to
his hollow stump bungalow when, all at once he saw a hammock
swinging between two trees near the edge of the wood.
In the hammock lay a boy with a thin, pale face, and beside him sat a
nurse, gently pulling on a rope that caused the little nest-like swinging
bed to sway to and fro.
"Oh ho!" thought Uncle Wiggily. "A sick boy! I'm sorry for him! He
won't be able to run around and have fun on Fourth of July as Jackie
and Peetie Bow Wow will."
And then the bunny heard the boy in the hammock speaking. And,
being able, as he was of late, to understand the talk of real persons,
Uncle Wiggily heard the boy say:
"Do you think I'll ever be able to run around again, and have fun, and
shoot off fire-crackers?"
"Of course you will," the nurse answered cheerfully.
"But I can't have any fire-crackers now, can I?" asked the boy, timidly,
as though knowing what the answer would be.
"No, Buddie! You are not quite well enough," the nurse gently replied.
"No fire-crackers for you!"
"How about torpedoes?"
"You couldn't have those, either, I'm afraid," and the nurse smiled as
she leaned over to give the boy a drink of orange juice.
"Oh, dear!" sighed the boy in the hammock, just like that. "Oh, dear!"
Uncle Wiggily felt very sorry for him.
"I wish I could do something," thought the bunny gentleman. "This
boy won't have much fun on the Fourth of July—not even as much fun
as Curly and Floppy Twistytail, the piggie chaps, will have throwing
corncobs against a tin pan and making believe they are skyrockets."
"Oh, dear!" again sighed the boy in the hammock. "Oh, dear!"
"What's the matter now?" asked his nurse.
"I don't s'pose I could even have a Roman candle, or a pinwheel,
could I?" the invalid asked.
"Oh, indeed no!" laughed the nurse. "What a funny chap you are!"
But the boy didn't feel very funny.
Uncle Wiggily twinkled his pink nose. Then he put his tall, silk hat
firmly on his head and, tucking under his paw his red, white and blue
striped rheumatism crutch, off through the woods hopped the bunny
uncle.
"I'm going to get some Fourth of July for that boy," said Mr. Longears.
"He simply must have some."
Uncle Wiggily spent some time hopping here and there through the
woods, and early the next morning, when the real boys and girls were
shooting off real fire-crackers and torpedoes, and when the animal
lads and lassies were cracking sticks and making torpedoes from
broad, green leaves, Mr. Longears hopped to where the boy was, once
more, swinging in his hammock.
The boy's head was turned to one side, and he was looking at some
of his friends, over in the vacant lots, setting off fire-crackers. Uncle
Wiggily, when the nurse wasn't looking, tossed into the hammock,
from the bush behind which the bunny was hidden, a bundle of green
things. They fell near the boy's hands.
Hardly knowing what he was doing the sick lad pinched one of the
green things between his fingers.
"Pop!" it went.
"What's that?" cried the nurse. "It sounded like a fire-cracker."
The boy pinched another green leaf-like ball between his fingers.
"Pop!" sounded again, as the ball burst.
"Why," cried the nurse. "That's like a torpedo! What have you there,
Buddie?"
"I don't know," the boy answered. "But these round, green balls, that
burst and pop when I squeeze them, fell into my hammock. There's a
lot of 'em! I can pinch them and make a noise for Fourth of July."
"So you can!" exclaimed the nurse, pinching one herself, and jumping
when it went "Pop!"
"And they won't hurt me, will they?" asked the boy.
"No," answered the nurse, "they won't hurt you at all. They must have
fallen off this tree, but I never knew, before, that such things as green
fire-crackers grew on trees!"
"Ha! Ha!" laughed Uncle Wiggily to himself, hidden under a bush.
"She doesn't know I brought the puff balls to the boy."
For that is what the bunny had done. In the woods he had found the
green puff balls, inside which were the seeds of the plant. Later on, in
the fall, the puff balls would be dry, and would crackle when you
touched them, opening to scatter the seeds. But now, being green,
and filled with air, they burst with a Fourth of July noise when
squeezed.
"Oh, now I can have some fun!" laughed the sick boy, as he cracked
one puff ball after another. "Hurrah! Now I'm celebrating Fourth of
July!"
And he was. Uncle Wiggily had helped him, and the bunny gentleman
had brought enough puff balls to last all day.
"Pop! Pop!" That is how they sounded as the boy pinched them in his
hammock. Some were large, like big fire-crackers, and others were
small, like little torpedoes.
"Oh, what a lovely Fourth of July!" sighed the boy, when evening
came to put the sun to bed, and the nurse wheeled the boy into the
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!

ebookfinal.com

You might also like