100% found this document useful (2 votes)
20 views57 pages

Essentials of MATLAB Programming 3rd Edition Chapman Solutions Manual Download

The document provides information on various MATLAB solutions manuals available for download, including titles like 'Essentials of MATLAB Programming' and 'MATLAB Programming for Engineers.' It also explains the differences between script files and functions in MATLAB, detailing how functions operate in their own workspace and utilize a pass-by-value scheme. Additionally, the document includes examples of MATLAB functions for sorting arrays and performing trigonometric operations in degrees.

Uploaded by

bremmverny
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
100% found this document useful (2 votes)
20 views57 pages

Essentials of MATLAB Programming 3rd Edition Chapman Solutions Manual Download

The document provides information on various MATLAB solutions manuals available for download, including titles like 'Essentials of MATLAB Programming' and 'MATLAB Programming for Engineers.' It also explains the differences between script files and functions in MATLAB, detailing how functions operate in their own workspace and utilize a pass-by-value scheme. Additionally, the document includes examples of MATLAB functions for sorting arrays and performing trigonometric operations in degrees.

Uploaded by

bremmverny
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/ 57

Essentials of MATLAB Programming 3rd Edition

Chapman Solutions Manual install download

https://testbankfan.com/product/essentials-of-matlab-
programming-3rd-edition-chapman-solutions-manual/

Download more testbank from https://testbankfan.com


We believe these products will be a great fit for you. Click
the link to download now, or visit testbankfan.com
to discover even more!

MATLAB Programming for Engineers 5th Edition Chapman


Solutions Manual

https://testbankfan.com/product/matlab-programming-for-
engineers-5th-edition-chapman-solutions-manual/

MATLAB Programming with Applications for Engineers 1st


Edition Chapman Solutions Manual

https://testbankfan.com/product/matlab-programming-with-
applications-for-engineers-1st-edition-chapman-solutions-manual/

Introduction to MATLAB 3rd Edition Etter Solutions


Manual

https://testbankfan.com/product/introduction-to-matlab-3rd-
edition-etter-solutions-manual/

Introduction to MATLAB Programming and Numerical


Methods for Engineers 1st Edition Siauw Solutions
Manual

https://testbankfan.com/product/introduction-to-matlab-
programming-and-numerical-methods-for-engineers-1st-edition-
siauw-solutions-manual/
Matlab A Practical Introduction to Programming and
Problem Solving 4th Edition Attaway Solutions Manual

https://testbankfan.com/product/matlab-a-practical-introduction-
to-programming-and-problem-solving-4th-edition-attaway-solutions-
manual/

MATLAB A Practical Introduction to Programming and


Problem Solving 5th Edition Attaway Solutions Manual

https://testbankfan.com/product/matlab-a-practical-introduction-
to-programming-and-problem-solving-5th-edition-attaway-solutions-
manual/

Engineers Guide To MATLAB 3rd Edition Magrab Solutions


Manual

https://testbankfan.com/product/engineers-guide-to-matlab-3rd-
edition-magrab-solutions-manual/

Digital Signal Processing using MATLAB 3rd Edition


Schilling Solutions Manual

https://testbankfan.com/product/digital-signal-processing-using-
matlab-3rd-edition-schilling-solutions-manual/

Essentials of Economics 3rd Edition Krugman Solutions


Manual

https://testbankfan.com/product/essentials-of-economics-3rd-
edition-krugman-solutions-manual/
6. Basic User-Defined Functions
6.1 Script files are just collections of MATLAB statements that are stored in a file. When a script file is
executed, the result is the same as it would be if all of the commands had been typed directly into
the Command Window. Script files share the Command Window’s workspace, so any variables that
were defined before the script file starts are visible to the script file, and any variables created by the
script file remain in the workspace after the script file finishes executing. A script file has no input
arguments and returns no results, but script files can communicate with other script files through the
data left behind in the workspace.

In contrast, MATLAB functions are a special type of M-file that run in their own independent
workspace. They receive input data through an input argument list, and return results to the caller
through an output argument list.

6.2 MATLAB programs communicate with their functions using a pass-by-value scheme. When a
function call occurs, MATLAB makes a copy of the actual arguments and passes them to the
function. This copying is very significant, because it means that even if the function modifies the
input arguments, it won’t affect the original data in the caller. Similarly, the returned values are
calculated by the function and copied into the return variables in the calling program.

6.3 The principal advantage of the pass-by-value scheme is that any changes to input arguments within a
function will not affect the input arguments in the calling program. This, along with the separate
workspace for the function, eliminates unintended side effects. The disadvantage is that copying
arguments, especially large arrays, can take time and memory.

6.4 A function to sort arrays in ascending or descending order, depending on the second calling
parameter, is shown below:

function out = ssort1(a,dir)


%SSORT1 Selection sort data in ascending or descending order
% Function SSORT1 sorts a numeric data set into ascending
% or descending order, depending on the value of the
% second parameter. If the parameter is 'up', then it
% sorts the data in ascending order. If the parameter is
% 'down', then it sorts the data in descending order. The
% default value is 'up'. Note that 'up' and 'down' may
% be abbreviated to 'u' and 'd', if desired.
%
% Note that the selection sort is relatively inefficient.
% DO NOT USE THIS FUNCTION FOR LARGE DATA SETS. Use MATLAB's
% "sort" function instead.

% Define variables:
% a -- Input array to sort
% ii -- Index variable
% iptr -- Pointer to min value
% jj -- Index variable
% nvals -- Number of values in "a"
% out -- Sorted output array
% temp -- Temp variable for swapping
129
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,2,nargin);
error(msg);

% If the direction argument is missing, set it to 'up'.


if nargin < 2
dir = 'up';
end

% Check for the direction of the sort


if dir(1) == 'u' | dir(1) == 'U'
sort_up = 1;
elseif dir(1) == 'd' | dir(1) == 'D'
sort_up = 0;
else
error('Second parameter is not ''UP'' or ''DOWN''!')
end

% Get the length of the array to sort


nvals = size(a,2);

% Sort the input array


for ii = 1:nvals-1

if sort_up

% Sort in ascending order.


% Find the minimum value in a(ii) through a(n)
iptr = ii;
for jj = ii+1:nvals
if a(jj) < a(iptr)
iptr = jj;
end
end

else

% Sort in descending order.


% Find the maximum value in a(ii) through a(n)
iptr = ii;
for jj = ii+1:nvals
if a(jj) < a(iptr)
iptr = jj;
end
end

end

130
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% iptr now points to the min/max value, so swap a(iptr)
% with a(ii) if ii ~= iptr.
if ii ~= iptr
temp = a(ii);
a(ii) = a(iptr);
a(iptr) = temp;
end
end

% Pass data back to caller


out = a;

A script file to test this function is shown below:

% Script file: test_ssort1.m


%
% Purpose:
% To read in an input data set, sort it into ascending
% order using the selection sort algorithm, and to
% write the sorted data to the Command window. This
% program calls function "ssort1" to do the actual
% sorting.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code
%
% Define variables:
% array -- Input data array
% ii -- Index variable
% nvals -- Number of input values
% sorted1 -- Sorted data array (up)
% sorted2 -- Sorted data array (down)

% Prompt for the number of values in the data set


nvals = input('Enter number of values to sort: ');

% Preallocate array
array = zeros(1,nvals);

% Get input values


for ii = 1:nvals

% Prompt for next value


string = ['Enter value ' int2str(ii) ': '];
array(ii) = input(string);

end

% Now sort the data in ascending order


sorted1 = ssort1(array,'up');

131
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Display the sorted result.
fprintf('\nSorted data in ascending order:\n');
for ii = 1:nvals
fprintf(' %8.4f\n',sorted1(ii));
end

% Now sort the data in descending order


sorted2 = ssort1(array,'down');

% Display the sorted result.


fprintf('\nSorted data in descending order:\n');
for ii = 1:nvals
fprintf(' %8.4f\n',sorted2(ii));
end

% Now sort the data in ascending order with


% no second argument.
sorted3 = ssort1(array);

% Display the sorted result.


fprintf('\nSorted data in default order:\n');
for ii = 1:nvals
fprintf(' %8.4f\n',sorted3(ii));
end

% The follwing call should produce an error message


sorted4 = ssort1(array,'bad');

When this program is executed, the results are:

» test_ssort1
Enter number of values to sort: 6
Enter value 1: -3
Enter value 2: 5
Enter value 3: 2
Enter value 4: 2
Enter value 5: 0
Enter value 6: 1

Sorted data in ascending order:


-3.0000
0.0000
1.0000
2.0000
2.0000
5.0000

Sorted data in descending order:


-3.0000
0.0000
1.0000
2.0000

132
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
2.0000
5.0000

Sorted data in default order:


-3.0000
0.0000
1.0000
2.0000
2.0000
5.0000
??? Error using ==> ssort1
Second parameter is not 'UP' or 'DOWN'!

Error in ==> C:\data\book\matlab_essentials\3e\soln\Ex5.4\test_ssort1.m


On line 66 ==>

6.5 A set of functions to perform trigonometric operations in degrees is shown below:

function out = sind(x)


%SIND Calculate sin(x), where x is in degrees
% Function SIND calculates sin(x), where x is in degrees
%
% Define variables:
% x -- Angle in degrees

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = sin(pi/180*x);

function out = sind(x)


%COSD Calculate cos(x), where x is in degrees
% Function COSD calculates cos(x), where x is in degrees
%
% Define variables:
% x -- Angle in degrees

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

133
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Calculate value
out = cos(pi/180*x);

function out = tand(x)


%TAND Calculate tan(x), where x is in degrees
% Function TAND calculates tan(x), where x is in degrees
%
% Define variables:
% x -- Angle in degrees

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = tan(pi/180*x);

function out = asind(x)


%ASIND Calculate asin(x), where the output is in degrees
% Function ASIND calculates asin(x), where the output is in degrees
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = 180/pi * asin(x);

function out = acosd(x)


%ACOSD Calculate acos(x), where the output is in degrees
% Function ACOSD calculates acos(x), where the output is in degrees
%
% Define variables:
% x -- Input value

% Record of revisions:

134
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = 180/pi * acos(x);

function out = atand(x)


%ATAND Calculate atan(x), where the output is in degrees
% Function ATAND calculates atan(x), where the output is in degrees
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = 180/pi * atan(x);

function out = atan2d(y,x)


%ATAN2D Four quadrant inverse tangent, where the output is in degrees
% Function ATAN2D calculates the Four quadrant inverse tangent, where
% the output is in degrees.
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(2,2,nargin);
error(msg);

% Calculate value
out = 180/pi * atan2(y,x);

A script file to test these functions is given below:

135
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Script file: test_functions.m
%
% Purpose:
% To perform a median filter on an input data set.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/03/15 S. J. Chapman Original code
%
% Define variables:
% ii -- Loop index
% filename -- Input data file
% n_ave -- Number of points to average
% n_per_side -- Number of points to average per side
% n_points -- Number of points in data set
% slope -- Slope of the line
% x -- Array of input values
% y -- Array of filtered values

disp('This program tests the trig functions that return answers in


degrees.');

% Set the angle theta = 30 degrees, and try the forward trig functions
disp(' ');
disp(['Testing forward trig functions:']);
disp(['sind(30) = ' num2str(sind(30))]);
disp(['cosd(30) = ' num2str(cosd(30))]);
disp(['tand(30) = ' num2str(tand(30))]);
disp(['sind(45) = ' num2str(sind(45))]);
disp(['cosd(45) = ' num2str(cosd(45))]);
disp(['tand(45) = ' num2str(tand(45))]);

% Test the inverse trig functions


disp(' ');
disp(['Testing inverse trig functions:']);
disp(['asind(0) = ' num2str(asind(0))]);
disp(['asind(1/sqrt(2)) = ' num2str(asind(1/sqrt(2)))]);
disp(['asind(1) = ' num2str(asind(1))]);
disp(['acosd(0) = ' num2str(acosd(0))]);
disp(['acosd(1/sqrt(2)) = ' num2str(acosd(1/sqrt(2)))]);
disp(['acosd(1) = ' num2str(acosd(1))]);
disp(['atand(1) = ' num2str(atand(1))]);

% Test atan2d
disp(' ');
disp(['Testing atan2d:']);
disp(['atan2d(4,3) = ' num2str(atan2d(4,3))]);

When the script file is executed, the results are:

>> test_functions

136
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
This program tests the trig functions that return answers in degrees.

Testing forward trig functions:


sind(30) = 0.5
cosd(30) = 0.86603
tand(30) = 0.57735
sind(45) = 0.70711
cosd(45) = 0.70711
tand(45) = 1

Testing inverse trig functions:


asind(0) = 0
asind(1/sqrt(2)) = 45
asind(1) = 90
acosd(0) = 90
acosd(1/sqrt(2)) = 45
acosd(1) = 0
atand(1) = 45

Testing atan2d:
atan2d(4,3) = 53.1301

6.6 A function to convert degrees Fahrenheit to degrees Celsius is shown below:

function deg_c = f_to_c(deg_f)


%F_TO_C Convert degrees Fahrenheit to degrees Celsius
% Function F_TO_C converts degrees Fahrenheit to degrees Celsius
% %
% Calling sequence:
% deg_c = f_to_c(deg_f)

% Define variables:
% deg_f -- Input in degrees Fahrenheit
% deg_c -- Output in degrees Celsius

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
deg_c = 5/9 * (deg_f - 32);

We can test this function using the freezing and boiling points of water:

>> f_to_c(32)
ans =
0
>> f_to_c(212)

137
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
ans =
100

6.7 A function to convert degrees Celsius to degrees Fahrenheit is shown below:

function deg_f = c_to_f(deg_c)


%C_TO_F Convert degrees Celsius to degrees Fahrenheit
% Function C_TO_F converts degrees Celsius to degrees Fahrenheit
% %
% Calling sequence:
% deg_f = c_to_f(deg_c)

% Define variables:
% deg_c -- Input in degrees Celsius
% deg_f -- Output in degrees Fahrenheit

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
deg_f = 9/5 * deg_c + 32;

We can test this function using the freezing and boiling points of water:

>> f_to_f(0)
ans =
100
>> c_to_f(100)
ans =
0

We can also show that c_to_f and f_to_c are the inverses of each other:

>> f_to_c(c_to_f(30))
ans =
30

6.8 A function to calculate the area of a triangle specified by the locations of its three vertices is shown
below:

function area = area2d(x1, y1, x2, y2, x3, y3)


%AREA2D Calculate the area of a triangle specified by three vertices
% Function AREA2D calculates the area of a triangle specified by
% three vertices
%
% Calling sequence:
% area = area2d(x1, y1, x2, y2, x3, y3)

138
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Define variables:
% x1, y1 -- Location of vertex 1
% x2, y2 -- Location of vertex 2
% x3, y3 -- Location of vertex 3
% area -- Area of triangle

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(6,6,nargin);
error(msg);

% Calculate value
area = 0.5 * (x1*(y2-y3) - x2*(y1-y3) + x3*(y1-y2));

We can test this function using the specified points:

>> area = area2d(0,0,10,0,15,5)


area =
25.00

6.9 At this point in our studies, there is no general way to support an arbitrary number of arguments in a
function. Function nargin allows a developer to know how many arguments are used in a
function call, but only up to the number of arguments in the calling sequence1. We will design this
function to support up to 6 vertices. The corresponding function is shown below:

function area = area_polygon(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)
%AREA_POLYGON Calculate the area of a polygon specified by its vertices
% Function AREA_POLYGON calculates the area of a polygon specified by
% its vertices
%
% Calling sequence:
% area = area_polygon(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)

% Define variables:
% ii -- Loop index
% n_vertices -- Number of vetices in polygon
% x1, y1 -- Location of vertex 1
% x2, y2 -- Location of vertex 2
% x3, y3 -- Location of vertex 3
% x4, y4 -- Location of vertex 4
% x5, y5 -- Location of vertex 5
% x6, y6 -- Location of vertex 6
% area -- Area of polygon

% Record of revisions:
% Date Programmer Description of change

1 Later we will learn about function varargin, which can support any number of arguments.
139
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


% There must be at least 3 vertices, and no more than 6.
msg = nargchk(6,12,nargin);
error(msg);

% Get the number of vertices


n_vertices = nargin / 2;

% Save vertices in arrays


x = zeros(1,n_vertices);
y = zeros(1,n_vertices);

% Save values
x(1) = x1;
y(1) = y1;
x(2) = x2;
y(2) = y2;
x(3) = x3;
y(3) = y3;
if n_vertices >= 4
x(4) = x4;
y(4) = y4;
end
if n_vertices >= 5
x(5) = x5;
y(5) = y5;
end
if n_vertices >= 6
x(6) = x6;
y(6) = y6;
end

% Calculate the area


area = 0;
for ii = 1:n_vertices-2
area = area + 0.5 * (x(ii)*(y(ii+1)-y(ii+2)) ...
- x(ii+1)*(y(ii)-y(ii+2)) ...
+ x(ii+2)*(y(ii)-y(ii+1)));
end

We can test this function using the specified point (0,0), (10,0), (10,10), and (0, 10), which
corresponds to a square with all sides having length 10:

>> area = area_polygon(0,0,10,0,10,10,0,10)


area =
100.00

We can test this function using the points specified in the problem:

>> area = area_polygon(0,0,10,0,10,10,0,10)

140
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
area =
100.00
>> area = area_polygon(10,0,8,8,2,10,-4,5)
area =
43.00

6.10 A function to calculate the inductance of a single-phase two-wire transmission line is shown below:

function ind = inductance(r, D, length)


%INDUCTANCE Calculate the inductance of a transmission line
% Function INDUCTANCE calculates the inductance of a
% single-phase two-wire transmission line.
%
% Calling sequence:
% ind = inductance(r, D, length)
%
% where
% r = the radius of the conductors in meters
% D = the distance between the two lines in meters
% length = Length of transmission line in meters

% Define variables:
% ind_per_m -- Inductance per meter

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(3,3,nargin);
error(msg);

% Constants
mu0 = pi * 4e-7; % H/m

% Calculate the inductance


ind_per_m = mu0 / pi * (1/4 + log(D/r));

% Get the inductance


ind = ind_per_m * length;

We can test this function using the points specified in the problem:

>> ind = inductance(0.02, 1.5, 100000)


ind =
0.1827

6.11 If the diameter of a transmission line’s conductors increase, the inductance of the line will decrease.
If the diameter of the conductors are doubled, the inductance will fall to:

>> ind = inductance(0.02, 1.5, 100000)


ind =

141
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
0.1550

6.12 A function to calculate the capacitance of a single-phase two-wire transmission line is shown below:

function cap = capacitance(r, D, length)


%CAPACITANCE Calculate the capacitance of a transmission line
% Function CAPACITANCE calculates the capacitance of a
% single-phase two-wire transmission line.
%
% Calling sequence:
% cap = capacitance(r, D, length)
%
% where
% r = the radius of the conductors in meters
% D = the distance between the two lines in meters
% length = Length of transmission line in meters

% Define variables:
% cap_per_m -- Capacitance per meter

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(3,3,nargin);
error(msg);

% Constants
e0 = pi * 4e-7; % F/m

% Calculate the capacitance


cap_per_m = pi * e0 / log((D-r)/r);

% Get the capacitance


cap = cap_per_m * length;

We can test this function using the points specified in the problem:

>> cap = capacitance(0.04, 1.5, 100000)


cap =
0.1097

6.13 If the distance between the two conductors increases, the inductance of the transmission line
increases and the capacitance of the transmission line decreases.

6.14 A program to compare the sorting times using the selection sort of Example 6.2 and MATLAB’s
built-in sort is shown below:

% Script file: compare_sorts.m


%
% Purpose:

142
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% To compare the sort function from Example 6.2 and the
% built-in MATLAB sort
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/05/15 S. J. Chapman Original code
%
% Define variables:
% data1 -- Array to sort
% data2 -- Copy of array to sort
% elapsed_time1 -- Elapsed time for ssort
% elapsed_time2 -- Elapsed time for sort

% Constants
SIZE = 100000; % Number of values to sort

% Set seed
seed(123456);

% Create a sample data set to sort.


data1 = random0(1,SIZE);

% Sort using ssort


data2 = data1;
tic;
out = ssort(data2);
elapsed_time1 = toc;

% Sort using sort


data2 = data1;
tic;
out = sort(data2);
elapsed_time2 = toc;

% Display the relative times


disp(['Sort time using ssort = ' num2str(elapsed_time1)]);
disp(['Sort time using sort = ' num2str(elapsed_time2)]);

When this program is executed, the results are:

>> compare_sorts
Sort time using ssort = 71.2407
Sort time using sort = 0.0060984

The built-in sorting function is dramatically faster than the selection sort of Example 6.2.

6.15 A program to compare the sorting times using the selection sort of Example 6.2 and MATLAB’s
built-in sort is shown below.

% Script file: compare_sorts.m


%
% Purpose:

143
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% To compare the sort function from Example 6.2 and the
% built-in MATLAB sort
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 07/04/11 S. J. Chapman Original code
%
% Define variables:
% data1 -- Array to sort
% data2 -- Copy of array to sort
% elapsed_time1 -- Elapsed time for ssort
% elapsed_time2 -- Elapsed time for sort

% Set seed
seed(123456);

% Create a sample data set to sort


nsamp = 10000;
data1 = random0(1,nsamp);

% Sort using ssort


data2 = data1;
tic;
out = ssort(data2);
elapsed_time1 = toc;

% Sort using sort


data2 = data1;
tic;
out = sort(data2);
elapsed_time2 = toc;

% Display the relative times


disp(['Sort time for ' int2str(nsamp) ' using ssort = ' num2str(elapsed_time1)]);
disp(['Sort time for ' int2str(nsamp) ' using sort = ' num2str(elapsed_time2)]);

% Create a sample data set to sort


nsamp = 100000;
data1 = random0(1,nsamp);

% Sort using ssort


data2 = data1;
tic;
out = ssort(data2);
elapsed_time1 = toc;

% Sort using sort


data2 = data1;
tic;
out = sort(data2);
elapsed_time2 = toc;

144
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Display the relative times
disp(['Sort time for ' int2str(nsamp) ' using ssort = ' num2str(elapsed_time1)]);
disp(['Sort time for ' int2str(nsamp) ' using sort = ' num2str(elapsed_time2)]);

% Create a sample data set to sort


nsamp = 200000;
data1 = random0(1,nsamp);

% Sort using ssort


data2 = data1;
tic;
out = ssort(data2);
elapsed_time1 = toc;

% Sort using sort


data2 = data1;
tic;
out = sort(data2);
elapsed_time2 = toc;

% Display the relative times


disp(['Sort time for ' int2str(nsamp) ' using ssort = ' num2str(elapsed_time1)]);
disp(['Sort time for ' int2str(nsamp) ' using sort = ' num2str(elapsed_time2)]);

The built-in sorting function is dramatically faster than the selection sort of Example 6.2.

>> compare_sorts
Sort time for 10000 using ssort = 0.71161
Sort time for 10000 using sort = 0.000634
Sort time for 100000 using ssort = 70.9728
Sort time for 100000 using sort = 0.0036683
Sort time for 200000 using ssort = 286.6228
Sort time for 200000 using sort = 0.006115

The time for the selection sort is increasing roughly as the square of the number of samples being
sorted. For example, it takes 71 s for 100,000 samples, and 287 s for 200,000 samples. The number
of samples doubles, and the time goes up as 22. The MATLAB sort time increases much more
slowly.

6.16 A modified version of function random0 that can accept 0, 1, or 2 arguments is shown below:

function ran = random0(n,m)


%RANDOM0 Generate uniform random numbers in [0,1)
% Function RANDOM0 generates an array of uniform
% random numbers in the range [0,1). The usage
% is:
%
% random0(n) -- Generate an n x n array
% random0(n,m) -- Generate an n x m array

% Define variables:
% ii -- Index variable
% ISEED -- Random number seed (global)

145
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% jj -- Index variable
% m -- Number of columns
% msg -- Error message
% n -- Number of rows
% ran -- Output array
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 02/04/14 S. J. Chapman Original code
% 1. 04/05/15 S. J. Chapman Modified for 0 arguments

% Declare global values


global ISEED % Seed for random number generator

% Check for a legal number of input arguments.


msg = nargchk(0,2,nargin);
error(msg);

% If both arguments are missing, set to 1.


% If the m argument is missing, set it to n.
if nargin < 1
m = 1;
n = 1;
elseif nargin < 2
m = n;
end

% Initialize the output array


ran = zeros(n,m);

% Now calculate random values


for ii = 1:n
for jj = 1:m
ISEED = mod(8121*ISEED + 28411, 134456 );
ran(ii,jj) = ISEED / 134456;
end
end

6.17 Function random0 has a bug under some conditions. If the global variable ISEED has not been
previously defined when random0 is executed, the program will crash. This problem occurs the
first time only that random0 is executed in a given MATLAB session, if function seed is not
called first. A simple way to avoid this problem would be to detect if ISEED is undefined, and to
supply a default value. Otherwise, the function should use the global seed supplied. A modified
version of random0 that fixes this bug is shown below:

function ran = random0(n,m)


%RANDOM0 Generate uniform random numbers in [0,1)
% Function RANDOM0 generates an array of uniform
% random numbers in the range [0,1). The usage
% is:
%
% random0(n) -- Generate an n x n array

146
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% random0(n,m) -- Generate an n x m array

% Define variables:
% ii -- Index variable
% ISEED -- Random number seed (global)
% jj -- Index variable
% m -- Number of columns
% msg -- Error message
% n -- Number of rows
% ran -- Output array

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 02/04/14 S. J. Chapman Original code
% 1. 04/05/15 S. J. Chapman Modified to provide initial seed

% Declare globl values


global ISEED % Seed for random number generator

% Check for a legal number of input arguments.


msg = nargchk(1,2,nargin);
error(msg);

% If the m argument is missing, set it to n.


if nargin < 2
m = n;
end

% Initialize the output array


ran = zeros(n,m);

% Test for missing seed, and supply a default if necessary.


if isempty(ISEED)
ISEED = 99999;
end

% Now calculate random values


for ii = 1:n
for jj = 1:m
ISEED = mod(8121*ISEED + 28411, 134456 );
ran(ii,jj) = ISEED / 134456;
end
end

6.18 A function dice to simulate the roll of a fair die is shown below:

function result = dice()


%DICE Return a random integer between 1 and 6
% Function DICE simulates the throw of a fair
% die. It returns a random integer between 1
% and 6.

147
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% Define variables:
% result -- Resulting integer

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(0,0,nargin);
error(msg);

% The value "6*random0(1,1)" returns a value


% in the range [0,6). The "floor" function
% returns {0,1,2,3,4,5} with equal probability,
% so "result" returns 1-6.
result = floor( 6 * random0(1,1) ) + 1;

A script file to test function dice is shown below:

% Script file: test_dice.m


%
% Purpose:
% To test the function dice. This function calls dice
% 10,000 times, and examines the distribution of the
% resulting values. They should be roughly uniform.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code
%
% Define variables:
% ii -- index variable
% result -- Array of results

% Initial values
result = zeros(1,100000);
for ii = 1:100000;
result(ii) = dice;
end

% Display the first 30 values.


fprintf('The first 30 values are:\n');
for ii = 1:30
fprintf('%d ',result(ii));
end
fprintf('\n');

% Now calculate a histogram to determine the overall


% distribution of numbers.
hist(result,6);
title('\bfHistogram of values returned from function "dice"');

148
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
xlabel('\bfValue');
ylabel('\bfCount');

When this script file is executed, the results are:

» test_dice
The first 30 values are:
3 1 4 6 6 4 4 4 1 6 6 4 1 2 1 3 2 6 1 2 2 6 6 5 6 3 1 6 1 5

The resulting histogram is shown below. The histogram shows that each integer between 1 and 6 is
about equally likely to occur.

6.19 A function to calculate a probability from the Poisson distribution is shown below:

function result = poisson(k, t, lambda)


%POISSON Return a random integer between 1 and 6
% Function POISSON calculates a sample value from
% the Poisson distribution for specific values of
% k, t, and lambda.

% Define variables:
% fact -- k! (k-factorial)
% result -- Resulting value from distribution

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================

149
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% 04/06/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(3,3,nargin);
error(msg);

% Calculate k!
fact = factorial(k);

% Calculate value from Poisson distribution.


result = exp(-lambda*t) * (lambda*t) ^ k / fact;

A program that uses function poisson to calculate the probability of a specific number of cars
passing a point on a highway in a given period of time is shown below:

% Script file: traffic.m


%
% Purpose:
% To calculate the probability of a given number of cars
% passing a particular point on a highway in a given time.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code
%
% Define variables:
% k -- Actual number of cars in time t
% lambda -- Expected number of cars per minute
% prob -- Probability array
% t -- Period of time (minutes)

% Get initial values


lambda = input('Enter expected number of cars/minute: ');
t = input('Enter period of time in minutes: ');

% Calculate values. Note that k runs from 0 to 5, while the


% minimum value for a MATLAB array is 1, so we must index into
% the MATLAB array using "k+1" instead of "k".
for k = 0:5
prob(k+1) = poisson(k, t, lambda);
end

% Display results
disp(['The probability of k cars passing in ' num2str(t) ' minutes is:']);
for k = 0:5
fprintf(' %3d %12.7f\n',k,prob(k+1));
end

% Now plot the distribution.


figure(1);
plot(0:5,prob,'bo','LineWidth',2);
title('\bfPoisson Distribution');

150
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
xlabel('\bfValue');
ylabel('\bfProbability');

When this program is executed, the results are as shown below. Note that the plot of the probability
distribution uses discrete points instead of a continuous line, since the probabilities are only defined
for the integer values k = 0, 1, 2, 3, … (we can’t have 1.2 cars go by!). This plot can also be
represented as a bar chart, once we learn how to create them in Chapter 6.

>> traffic
Enter expected number of cars/minute: 1.6
Enter period of time in minutes: 1
The probability of k cars passing in 1 minutes is:
0 0.2018965
1 0.3230344
2 0.2584275
3 0.1378280
4 0.0551312
5 0.0176420

6.20 Functions to calculate the hyperbolic sine, cosine, and tangent functions are shown below:

function out = sinh(x)


%SIND Calculate hyperbolic sine function
% Function SINH calculates the hyperbolic sine function
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change

151
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = (exp(x) - exp(-x))/2;

function out = cosh1(x)


%COSH1 Calculate hyperbolic cosine function
% Function COSH1 calculates the hyperbolic cosine function
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = (exp(x) + exp(-x))/2;

function out = tanh1(x)


%TANH1 Calculate hyperbolic tangent function
% Function TANH1 calculates the hyperbolic tangent function
%
% Define variables:
% x -- Input value

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 07/12/11 S. J. Chapman Original code

% Check for a legal number of input arguments.


msg = nargchk(1,1,nargin);
error(msg);

% Calculate value
out = (exp(x) - exp(-x)) ./ (exp(x) + exp(-x));

A script file to plot the hyperbolic sine, cosine, and tangent functions are shown below:

% Script file: test_hyperbolic_functions.m


%
% Purpose:

152
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% To plot the hyperbolic functions sinh, cosh, abd tanh.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/06/15 S. J. Chapman Original code
%
% Define variables:
% out_cosh -- Hyperbolic cosine
% out_sinh -- Hyperbolic sine
% out_tanh -- Hyperbolic tangent

% Calculate results
x = -5:0.05:5;
out_cosh = cosh1(x);
out_sinh = sinh1(x);
out_tanh = tanh1(x);

% Display results
figure(1);
plot(x,out_cosh);
title('\bfHyperbolic cosine');
xlabel('\bfx');
ylabel('\bfcosh(x)');
grid on;

figure(2);
plot(x,out_sinh);
title('\bfHyperbolic sine');
xlabel('\bfx');
ylabel('\bfsinh(x)');
grid on;

figure(3);
plot(x,out_cosh);
title('\bfHyperbolic tangent');
xlabel('\bfx');
ylabel('\bftanh(x)');
grid on;

The resulting plots are shown below:

153
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
154
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
6.21 A function to smooth a noisy data set with a running average filter is shown below.

function y = running_ave(x,n_ave)
%RUNNING_AVE Function to perform a running average filter
% Function RUNNING_AVE performs a running average filter
%
% Calling sequence:
% y = running_ave(x, n_ave)
%
% where:
% n_ave -- Number of points to average
% x -- Array of input values
% y -- Array of filtered values

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/08/15 S. J. Chapman Original code

% Define local variables:


% ii -- Loop index
% n_per_side -- Number of points to average per side
% n_points -- Number of points in data set
% slope -- Slope of the line

% Check for a legal number of input arguments.


msg = nargchk(1,2,nargin);

155
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
error(msg);

% Set a default number of points to average if this value


% is undefined.
if nargin < 2
n_ave = 7;
end

% Get the number of samples on either side of the sample


% being averaged, dropping any fractional part.
n_per_side = (n_ave-1) / 2;
n_per_side = floor(n_per_side);

% Get the number of points in the input structure


n_points = length(x);

% Now perform the running average


for ii = 1:n_points

% Check to see how many points we can use on either side


% of the point being averaged.
n_low = min([ (ii-1) n_per_side]);
n_high = min([ (n_points-ii) n_per_side]);
n_used = min([ n_low n_high]);

% Now calculate running average


y(ii) = sum(x(ii-n_used:ii+n_used)) / (2*n_used+1);

end

A program to test this function is shown below.

% Script file: test_running_ave.m


%
% Purpose:
% To perform test the running average filter function.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/08/15 S. J. Chapman Original code
%
% Define variables:
% ii -- Loop index
% filename -- Input data file
% n_ave -- Number of points to average
% n_per_side -- Number of points to average per side
% n_points -- Number of points in data set
% x -- Array of input values
% y -- Array of filtered values

disp('This program performs a running average filter on an ');


disp('input data set.');

156
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
filename = input('Enter the filename containing the data: ','s');
n_ave = input('Enter the number of samples to average: ');

% Get the number of samples on either side of the sample


% being averaged, dropping any fractional part.
n_per_side = (n_ave-1) / 2;
n_per_side = floor(n_per_side);

% Read the input data


x = textread(filename,'%f');
n_points = length(x);

% Get running average


y = running_ave(x,n_ave);

% Plot the data points as blue circles with no


% connecting lines.
plot(x,'bo');
hold on;

% Plot the fit as a solid red line with no markers


plot(y,'r-','LineWidth',2);
hold off;

% Add a title and legend


title ('\bfRunning-Average Filter');
xlabel('\bf\itx');
ylabel('\bf\ity');
legend('Input data','Fitted line');
grid on

When this program is executed, the results are:

>> test_running_ave
This program performs a running average filter on an
input data set.
Enter the filename containing the data: input3.dat
Enter the number of samples to average: 7

157
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
6.22 A function to smooth a noisy data set with a median filter is shown below.

function y = median_filter(x,n_ave)
%RUNNING_AVE Function to perform a median filter
% Function RUNNING_AVE performs a median filter
%
% Calling sequence:
% y = median_filter(x, n_ave)
%
% where:
% n_ave -- Number of points to average
% x -- Array of input values
% y -- Array of filtered values

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 04/08/15 S. J. Chapman Original code

% Define local variables:


% ii -- Loop index
% n_per_side -- Number of points to average per side
% n_points -- Number of points in data set
% slope -- Slope of the line

% Check for a legal number of input arguments.


msg = nargchk(1,2,nargin);
158
© 2018 Cengage Learning®. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Exploring the Variety of Random
Documents with Different Content
without the least pretension; I wrote it in a quarter of an hour. We
may add that it was written with one of the pens of the great
Frederick, the only thing I brought away with me from Sans-Souci.
The quill possesses the further merit of having traced some plans of
battle, and some verses which were no better than mine.’
I complimented him, laughing.
‘Don’t laugh,’ he rejoined. ‘The history of the Congress is not
unlike the history of France, which, as Ménage averred, might be
written with a collection of light comedies interspersed with song, to
guide the author.’
Then, after a few moments of silence, ‘I’ll not admit the
paternity of this trifle, except to my friends. I have not forgotten the
Duchesse de Boufflers’ reward of the cocksure vanity of the Comte
77
de Tressan. I have nothing to oppose to the thousands of bayonets
of the occupants of thrones but so many words marshalled in line.
The struggle would not be equal.’
‘But to whom, prince, if not to you, should belong the privilege
of telling the truth?’
‘You mean in virtue of my age?’
I quickly changed the subject. This excellent prince always came
back to his regrets at being more or less put into the shade by men
who had only recently made good their names, and his comments
on current events, though devoid of all bitterness, were stamped
with a kind of sadness. I began talking to him about his military
writings, which he liked best of all, and to which he attached the
greatest importance. Posterity has judged differently. It has allotted
the foremost place to his clever witticisms, to his remarks on the
society, the manners and customs, and the artistic questions of his
time, in the writing of which his imagination found full play. The
soldier is almost entirely forgotten, but the sprightly and pungent
literary man, the impartial and quick observer, is admired as much as
ever.
‘I have left my works to my company of Trabans. They are the
reflections of an old soldier whose experience has been deemed
superfluous. At any rate, people will profit by it after my death.’
It was evident that the prince was in one of the fretful moods
that now and again assailed him as a set-off to his youthful gaiety.
His features became clouded, he took my arm; we had a short stroll
round the rooms, then went out and walked silently to his little
house on the rampart.
Next morning when I called I found him, contrary to his custom,
out of bed and seated in his library, which was at the same time his
bed- and reception-room, and which, smiling, he had named the last
bar of his perch.
‘You have come for the song. Just listen to it.’ And in a by no
means feeble voice he began to sing the trifle which was soon taken
78
up by all classes of society, including the sovereigns themselves.
‘Take this copy with you,’ said the prince; ‘my heirs will be none
the worse for this liberality on my part. It is different with regard to
these two manuscripts which I am just touching up. One deals with
considerations on the disastrous Austrian campaigns during the first
years of the French Revolution; the other treats of the campaigns in
Italy up to Marengo. Both are not without interest. But,’ interrupting
himself, ‘while I am making songs on the Congress, what becomes
of it? Have you got any news?’
‘None, prince, not a syllable of what transpires leaks out. To tell
the truth, people do not appear to concern themselves much with
regard to it. There is, however, a great deal of talk about a ball
Emperor Alexander proposes to give to the sovereigns at Prince
Razumowski’s mansion on St. Catherine’s night, the fête-day of the
Grand-Duchess of Oldenburg.’
‘That’s right, those poor kings ought to have a holiday. I am not
certain, though, that at the end of all these entertainments any of
the monarchs will be able to say to himself what my dear Joseph II.
said. When he had worked the whole of the day at the reforms
which, while immortalising his name, contributed to the happiness of
the empire, he said, lightly tapping his cheek, “And now, go to bed,
Joseph, I am pleased with your day’s work.”
‘Amidst this cross-fire of different pretensions, have you heard
anything of a claim of another kind? Trifling though it may be, it is
calculated to provide some occupation for the archons of the
Congress. It is a note presented by Louis Buon-Compagni, Prince of
Lucca and Piombino, claiming sovereign rights over the island of
Elba. He considers the investment of Napoleon with that sovereignty
out of order and out of place. His claim is supported by a document,
in which Emperor Ferdinand acknowledges to have received from
one of his ancestors, Nicolas Ludovisi, Duc de Venosa, more than a
million of florins for the investiture of Elba and Piombino, granted to
him and his descendants. Here’s a pretty business—the man who
ruled the world threatened with ejectment by another Robinson
Crusoe! If Louis [Ludovico] Buon-Compagni would come down to the
rôle of Friday, matters might be arranged. But he wants his island,
and wants it all to himself. Trifling as the incident may appear, it
would lend itself to a very curious chapter. It would be the height of
absurdity to see the man who distributed crowns without a stone on
which to put his heroic head in an unknown island.’
Coming back to his favourite topic, the prince referred once
more to warlike matters, and in a manner as enthusiastic as if he
were twenty. At such moments his tall and beautiful figure drew
itself up to its full height, his features became animated, his eyes
positively brilliant. ‘Don’t imagine, my dear boy, that during two days
I have done nothing but concoct rhymes or epigrams on the
Congress. You see these two volumes; well, I have spent the night
in reading them.’
He pointed to a military work entitled Principes de Stratégie
appliqués aux Campagnes de 1796 en Allemagne. Its author, Arch-
Duke Charles, had sent them to him.
‘In this book, full of curious details and profound views,’ he said,
‘there is only one mistake as far as I can judge. The author is too
severe upon himself. There is not the faintest doubt about the
transcendent military worth of Prince Charles, but it is marked by so
much modesty and such simplicity of manner as to seem scarcely
reconcilable with his reputation. He is not only the greatest captain
of Austria, but more than once he has proved himself a counter-
balance to the genius of your Napoleon. In his valour, in his faculty
of inspiring both respect and obedience in his soldiers, he is like
Frederick; in his virtues, his strict integrity, and his unalterable love
of duty, he is the living image of the Prince Charles of Lorraine. The
frankness of his soul is reflected in his face. Some time ago I
attempted to draw his portrait in verse. I sent it to him anonymously,
knowing as I did that direct praise was apt to displease him. In some
way, I do not know how, he guessed the authorship. No doubt my
feelings got the better of my style, and I presume that the books he
sent me are intended as a reply. I have just finished reading them. I
feel certain of their becoming classical, for admiration instinctively
follows a public man admitted, as he is, to be possessed of a grand
and noble character.’
Then he drifted to the famous captains of his time and to their
notable exploits; and gradually I felt his enthusiasm gaining upon
me. His own genius was discernible in his looks, and electrified me.
The conversation of such men as he is more apt to enlighten one
and to speak louder than their books. Inasmuch as I had made up
my mind religiously to garner every literary scrap from the pen of
this encyclopedic man, I asked him to give me his verses on Prince
Charles, and I added them to my precious collection.
‘We’ll meet at Razumowski’s,’ he said, ‘seeing that, guided by
pleasure only, we are evidently advancing towards the great result of
this sapient assembly amidst balls, fêtes, carrousels, and games. No
doubt the day will come when we shall be allowed to know the fate
of Europe. Manifestly, though, experience does not appear to convey
any valuable lesson either to men’s passions or to their ambition;
and our era seems to have quickly forgotten a very recent past.
‘I must leave you, to preside at a chapter of the Order of Maria-
79
Theresa; the Commandeur-Général, Ouwaroff, is to be invested to-
day. From there I am going to dine with your great diplomatist.’
Since the cold weather had set in, making the Prater somewhat
too chilly for idlers and loungers on foot, the latter foregathered on
the Graben. The newspaper writers thronged the public resort, and,
in default of genuine particulars of the Congress, retailed their so-
called political information and Court stories, as devoid of probability,
not to say of truth, as the rest. Outdoor life had assumed such
proportions that one might have safely said to one’s friends in the
evening, ‘I looked for you on the Graben to-day. I failed to find you,
so I left my card.’ The Graben was to the majority of strangers what
the Square of St. Mark is to the Venetians. They spent the greater
part of their time there. It was a kind of open-air club; everybody
received and returned calls there; the life of the capital was
practically regulated on that spot; folk appointed to meet there to
discuss their future movements, and to organise pleasure parties for
the evening. Hence, it would be no exaggeration to say that people
lived in common on the Graben, amidst an immense group of
‘loafers,’ idlers, ‘spouters,’ and disputants.
There was another kind of store-house for news, epigrams, witty
sallies, and satirical observation; a kind of ‘lion’s mouth’ à la
Vénitienne, less the secret denunciations. Or rather, the place was
like the Marforio in Rome, I mean the statue at the foot of which
there was a constant flow of criticism both on the governors and on
the governed. The second spot was the big room of the ‘Empress of
Austria’ tavern, which I have already mentioned. Every day, at the
dinner-hour, the place was thronged with illustrious and important
personages, anxious to escape from the magnificent but somewhat
solemn banquets of the Austrian Court. At a ‘round table’ the
occupants vied with each other in challenges—not like those of the
ancient knights of King Arthur, but in wit-combats, sarcastic lunges,
and epigrams, all of them tempered by the perfect tone of Courts
and of the best society.
The constant variety of its patrons invested this improvised club
with the greatest interest. Among the habitués were the Chevalier
de Los Rios, Ypsilanti, Tettenborn, MM. Achille Rouen, Koreff,
Danilewski, the Prince Koslowski, Gentz, the secretary of the
Congress, the Comte de Witt, Carpani, the poet, ever so many
generals, ambassadors, and very often some royal highnesses.
Narischkine, the great-chamberlain, came now and again, treating
the company to his biting and dreaded sallies. In short, there was a
never-failing muster of all that Vienna held within its walls in the way
of political, artistic, and social celebrities.
The stories told there could have rightly been called the
‘Chronicle of the Congress,’ and even the ‘Chronicles of Europe’;
everybody of note, or of erewhile renown, being apparently
responsible for his doings and sayings to the jurisdiction of the
caustic Areopagus of that tavern.
Although the fare was in keeping with the company and the
conversation, prices were comparatively modest. In spite of the
number of strangers in Vienna at that moment, in spite of their rank
and their wealth, the cost of most things, except of lodgings, was
moderate. The Dutch ducat was worth twelve florins in paper, which
fact, doubling its value in money, increased the resources of a
stranger in that ratio. The whole may be judged from the fact that
meals, profusely served and supplemented with several kinds of
wine, were supplied at the rate of five florins per head.
Griffiths and I took our seats at one of the tables. They were
talking about the preparations for the fête next day at Razumowski’s,
and of the honour the emperor had bestowed upon him by creating
him a prince.
‘He deserved the distinction,’ said Koslowski. ‘The new prince,
since he has been our ambassador at Vienna, has made many
valuable friends. In the recent discussions on Poland, he was
instrumental in restoring harmony, and in putting an end to the little
pecking which threatened to become serious.’
‘Added to this,’ remarked the representative of a German
princelet, ‘there is a prerogative attached to his new title.
Henceforth, when going out at night he can have torch-bearers
running in front of him.’
The new prince having become the momentary target for the
remarks of everybody, there were, of course, many references to his
enormous fortune, which, when all was said and done, was only a
fraction of the wealth of his father, the marshal, who, greatly
favoured by Empress Elizabeth, became the wealthiest private
80
individual of Europe. He and Frederick had a curious little scene
one day. When the marshal was in Berlin the king held in his honour
a review of the troops who had gone through a score of campaigns.
In Russia all the dignities and functions are assimilated to
corresponding military grades, from the lowest to the topmost rung
of the ladder; nevertheless, the marshal had never seen a
battlefield.
‘I trust you are pleased, marshal,’ said the King of Prussia at the
termination of the manœuvres.
‘Much pleased indeed, sire, although the whole of it is altogether
beyond my competence; I am only a civil marshal.’
‘You are indeed very civil, marshal; unfortunately we have no
such grades in our army,’ replied Frederick.
Political gossip formed the main item of our conversation that
evening. ‘The intervention of Razumowski,’ remarked one of a group,
‘and his conciliatory efforts throughout have by no means been
rewarded too highly. The quarrel was getting envenomed, I have
been told. One of the most eminent of European plenipotentiaries
expressed himself in the course of the discussion with great firmness
upon Alexander’s pretensions to the throne of Poland. The Grand-
Duke Constantine got angry, and showed his anger by a somewhat
too energetic gesture, after which he left in hot haste. According to
well-informed people, the diplomatist is meditating a piece of
revenge. Considering that he is a man of wit, we may expect
something odd.’
‘No,’ replied another, ‘that’s not the cause of the grand-duke’s
abrupt departure. The minister in question wrote to Prince
Hardenberg some sentences calculated to displease the Russian
monarch. By a strange fatality the document fell into the hands of
Alexander, and this led to very lively explanations. Lord Castlereagh
sided with Austria. Matters reached such a point that one of the
monarchs, forgetting his usual reserve, flung his glove on the table.
‘“Would your majesty wish for war?” asked the English
plenipotentiary.
‘“Perhaps, monsieur.”
‘“I was not aware,” Castlereagh replied, “that any war was to be
undertaken without English guineas.” And appeasement,’ added the
speaker, ‘has not progressed an inch, in spite of the kindly efforts of
81
our new prince.’
‘Will the King of Saxony be reinstated in his kingdom in spite of
Prussia, which covets it? King Friedrich-Wilhelm is very angry with M.
de Talleyrand,’ said a third interlocutor. ‘The king lately remonstrated
with M. de Talleyrand for too warmly espousing the cause of the
Saxon monarch, that sole traitor, as he put it, to the cause of
Europe.
‘“Traitor!” echoed Talleyrand. “And from what date, sire?”
Honestly, Frederick-Augustus ought to be forgiven everything, if
there be anything to forgive, if for no other reason than the justice
of the repartee.’
‘That excellent prince has done much better than that,’ replied
an interlocutor. ‘Lest some untoward event should happen, he has
taken care to make a little purse for himself, from which he has
detached a few millions for the benefit of two personages disposing
of a great deal of influence in Vienna. This golden key will open the
doors of his kingdom much more quickly than all the protocols of the
Congress.’
All at once, and without the least transition, the talk turned on
Lord Stewart and on some mishaps due to his overweening conceit.
‘For the last four days,’ said some one, ‘his lordship has not been
seen on foot or in his magnificent carriage. According to rumour, his
face has been more or less damaged. He had a quarrel on the
Danube bridge with a couple of hackney drivers, and immediately
jumping off his seat, his excellency, waving his arms like the sails of
a windmill, challenged his adversaries to an English boxing match.
The Vienna coachman, however, knows nothing, either theoretically
or practically of “fisticuffs,” and consequently our two Automédons’
[the French equivalent for our ‘Jehu,’ and an allusion to Achilles’
charioteer] ‘bravely grasped their whips, and first with the thongs
and afterwards with the handles, belaboured his lordship with blows,
without the least respect for his “pretty” face. They left him lying on
the ground, bruised all over, and disappeared as quickly as their
horses would take them.
‘Milord has bad luck, but his conceit seems incorrigible. Lately,
on leaving the theatre, he happened to be behind the daughter of
the Comtesse Co—— on the grand staircase. There was a great
crush, and, taking advantage of it, his lordship was guilty of an act
of impudent familiarity, which he might have found to his cost could
only be washed out with blood. Without being in the least
disconcerted, the young, handsome, and innocent girl quietly turned
round and gave him a sound box on the ears, as a warning to leave
innocence and beauty alone. Naturally, his lordship has been the
laughing-stock of everybody, as he often is, for nothing waits so
surely upon conceit and fatuous vanity as derision.’
‘Have the Genoese envoys obtained an audience at last?’ asked
some one, ‘Or have they been driven away from all the diplomatic
doors at which they knocked for a hearing.’
‘They ought to be well pleased,’ was the answer. ‘Weaned with
their applications, M. de Metternich has given them the desired
interview and overwhelmed them with his politeness. They wish to
constitute themselves into an independent State. The minister
listened to every word they said, and when they left off speaking,
told them that Genoa would be incorporated with Piedmont. Our
Genoese objected violently. M. de Metternich told them that the
affair was settled, irrevocably settled, and bowed them out even
more politely than he “bowed them in.” He might have saved them
their breath.’
‘The Duchesse de ——, not to be behindhand with the Princesse
de ——, who has made her lover an ambassador, has made hers a
general, though he has never seen a battle. It’s of no consequence,
seeing that the Congress, in virtue of its wisdom, is to put an end to
all war both in the immediate and distant future.’
‘Love turns other heads besides these,’ chimed in the first
speaker. ‘A great personage happened to see a Viennese work-girl
somewhere on the ramparts, and has fallen a victim to her rosy face
and elegant figure. There’s no doubt about it; he is thoroughly in
love; he lavishes presents on his very easy conquest, and altogether
forgetting his rôle of sovereign, he has thrown all reserve to the
winds, and given her his portrait set with diamonds. In days gone by
the Court ladies would have objected to such a mésalliance.’
Some one threw in a word about the balls given by Lady
Castlereagh, and this led to remarks on his lordship’s pronounced
love for dancing. ‘The taste is easily explained, it belongs to all times
and all ages,’ was the comment. ‘Aspasia taught Socrates to dance;
and when he was fifty-six years old Cato the Censor danced even
more often than his lordship. It is doubtful whether either of these
made himself as ridiculous as that lank body of his lordship dancing
a jig, and lifting his long spindle-shanks, keeping time to the music.
It is indeed a diverting spectacle. What a windfall this would be to
those clever English caricaturists, if one could only get them to come
to Vienna! At any rate, the dancing master of his lordship, in case of
his becoming prime minister, will have no occasion to repeat what
the dancing master of the [Earl?] of Oxford said on learning that
Elizabeth had made his pupil her great-chancellor: “Truly, I fail to see
what merit the queen could find in this Barclay? I had him in hand
for two years, and was unable to make anything of him.”’
‘In spite of the express declaration of the sovereigns, who have
settled among themselves the questions of rank and precedence in
accordance with their age, disagreements on the subject crop up
every day,’ said somebody who had hitherto been silent. ‘The
bickering between the minister of Würtemberg and the Hanoverian
minister is without importance; nothing has come of it save the
retirement of the Würtemberger and the appointment of the Comte
de Wintzingerode in his stead. But the quarrel between the Princesse
de Lichtenstein and the Princesse Esterhazy is not so trivial. The one
claims precedence over the other in virtue of her husband being the
most ancient prince of the empire.’
‘It would be easy enough to settle that matter,’ was the reply
from the other side of the table. ‘Let them apply to those ladies the
rule adopted by the sovereigns; in other words, let age rule
precedence, and you may be sure that neither of them will want to
go first.’
‘Here is a strange pendant to the adventure of the too
conscientious Vatel, whose disappointment and death have been
immortalised by Mme. de Sévigné. The chef at Chantilly killed
himself because the fish for the dinner failed him; the Baron de ——
killed himself through having eaten too much fish.’
‘What’s the good of joking about such a sad event?’
‘I am not joking, I am telling you the unvarnished truth. The
poor deceased was a slave to etiquette, and having partaken too
freely of some delicious fish, he felt thoroughly uncomfortable in
consequence. He was invited to make a fourth at a rubber of whist
with the Grand-Duke of Baden, a Princesse de C——, and his
Majesty of Bavaria; and in spite of his bodily and moral agony, he
dared not refuse. But the ordeal proved too much, and when
concealment of the situation was no longer possible he rushed away,
went home, and shot himself. Everybody regrets his death, because
82
he was a general favorite.’
‘Your great diplomatist, this time in thorough agreement with the
majority of the plenipotentiaries, made another king yesterday,’ said
an opposite neighbour, addressing me directly.
‘Is it Prince Eugène?’ I exclaimed spontaneously.
‘Not exactly; it’s the cheese called “Brie.”’
‘You are trying to mystify me.’
‘I should not presume to do so on so slight an acquaintance, but
I can assure you that it is a fact. M. de Talleyrand gave a dinner
party, and at the dessert, all the political questions were pretty well
exhausted. When the cheese was on the table, the conversation
drifted in the direction of that dainty. Lord Castlereagh was loud in
praise of Stilton; Aldini was equally loud in praise of the Strachino of
Milan; Zeltner naturally gave battle for his native Gruyère, and Baron
de Falck, the Dutch minister, could not say enough for the product of
Limburg, of which Peter the Great was so fond as to dole himself a
certain quantity measured with his compasses, lest he should take
too much. Talleyrand’s guests were as undecided as they are on the
question of the throne of Naples, which, according to some, will be
taken from Murat, while, according to others, he’ll be allowed to
keep it. At that moment a servant entered the room to inform the
ambassador of the arrival of a courier from France. “What has he
brought?” asked Talleyrand. “Despatches from the Court, your
excellency, and Brie cheeses.” “Send the despatches to the
chancellerie, and bring in the cheeses at once.”
‘The cheese was brought in. “Gentlemen,” said M. de Talleyrand,
“I abstained just now from breaking a lance in favour of a product of
the French soil, but I leave you to judge for yourselves.” The cheese
is handed round, tasted, and the question of its superiority is put to
the vote, with the result I have told you: Brie is proclaimed to be the
king of cheeses.’
The clever little story was the last, and the company dispersed.
Griffiths and I were due at the Baron Arnstein’s, who gave a fête in
his magnificent mansion on the Melgrub.
At that period, the principal Austrian bankers would not be
behindhand with the Court in their hospitality to the illustrious
strangers at the Congress. Of course, the enormous influx of these
brought into the bankers’ hands large sums of money, a considerable
percentage of which remained with them. Among those princely
houses of finance there were, besides Baron Arnstein, the Gey-
Mullers, the Eskeleses, and the Comte de Fries. They practically kept
open house to strangers. The splendour of their hospitality was only
equalled by its cordiality. The mansion of the Comte de Fries, on the
Joseph-Platz, was one of the most beautiful in Vienna, and in no way
inferior to the most magnificent palaces. Its owner himself was as
famed for his personal elegance and his charming manners as for his
immense wealth. The fêtes that were given in those mansions were
remarkable even among those of the Congress; and on the evening
in question, the scene at Baron Arnstein’s was positively fairy-like.
The rarest flowers from every clime hung in profusion about the
staircases and the rooms, including the ball-room, and spread their
exquisite perfumes, while their tints mingled harmoniously with the
thousands of wax candles in crystal sconces, and the silk and gold of
the hangings. The music of a band such as at that time only Vienna
could produce fell gratefully upon the ear. In short, the whole
presented one of those incomparable results only to be obtained by
great wealth seconded by taste.
The best society of Vienna had forgathered there: all the
influential personages of the Congress, all the strangers of
distinction, all the heads of the princely houses made a point of
being present; only the sovereigns themselves were absent. As a
matter of course, all the charming women of which Vienna boasted
at that period had responded to the invitation, and among these
aristocratic beauties the hostess herself, the Baronne Fanny
d’Arnstein, and Mme. Gey-Muller, whom people had named ‘la fille
de l’air,’ on account of her ethereal face and tall, slight figure, carried
off the palm for attractiveness.
The entertainment began with a concert by the foremost artists
of Vienna; the concert was followed by a ball, and the ball by a
supper, in the providing for which the host seemed to have made it a
point to defy both distance and season. He had positively brought
together the products of every country and of every climate. The
supper rooms were decorated with trees bearing ripe fruit, and it
was really a curious experience, in the middle of the winter, to watch
people pluck cherries, peaches, and apricots as in an orchard in
Provence. It was the first attempt of the kind that had ever been
made, and we went home, less astonished perhaps at the ingenuity
displayed than at the constant craving for the entirely
unprecedented in the way of enjoyment.
The palace of Prince Razumowski was blazing with light; every
room was crowded with guests. Emperor Alexander had borrowed
his ambassador’s residence for a fête offered to the sovereigns in
honour of his sister’s birthday. The utmost interest was always
evinced in the charming Catherine of Oldenburg, and perhaps the
more because the Prince Royal of Würtemberg was constantly by her
side. At every gathering, these two young people, rarely far apart,
reminded one of the couple figuring so conspicuously in the opening
pages of Mme. de Genlis’s novel Mademoiselle de Clermont.
Marie Dowager Empress of Russia.

Love unquestionably owed a good turn to this sweet, pretty, and


graceful young woman, to indemnify her for the very unpleasant
episodes of her first marriage. In 1809, there had been a question of
an alliance between France and Russia, an alliance which would
have consolidated peace in Europe. The young sister of the Czar was
to be the pledge of that alliance. Napoleon, who at that period was
justified in looking upon Alexander as a friend, caused diplomatic
overtures to be made. The Russian monarch freely gave his
83
consent, but all at once a hitherto unthought-of obstacle arose, in
the shape of the invincible repugnance of the dowager-empress to
Napoleon, a repugnance that ought to have been removed by
Napoleon’s magnanimous conduct to her son. When Alexander
wished to sound his mother on that marriage by evincing a kind of
partiality for it, she replied that it was henceforth out of the
question, that two days previously she had given her word to the
Grand-Duke of Oldenburg, to whom Catherine’s hand was promised.
Alexander was a most respectful and submissive son. He offered no
objections; negotiations were broken off; the marriage of Napoleon
with an Austrian arch-duchess was concluded, and there was a
prospective sovereign for the island of Elba.
Sacrificed to a feeling of political repugnance, Catherine became
Grand-Duchess of Oldenburg and established her Court at Tiver, a
pretty town between Moscow and St. Petersburg—a small Court,
recalling those of Ferrara and Florence during the most brilliant days
of their artistic glory. Art, however, does not invariably contribute to
a woman’s happiness. United to a man whom she could not love, the
grand-duchess fretted under her lot. At first people sympathised with
her, finally they took no heed of, or became used to, her grief. Then,
as if to realise sweeter dreams, came on the one hand the death of
her husband, and on the other the love of a prince, young,
handsome, brave, and amiable—a prince placed on the steps of a
throne.
By a strange coincidence, the Prince Royal of Würtemberg had
been similarly compelled to contract a marriage against his
inclination. Napoleon’s will, all-powerful at that time over the king’s
mind, united the son, in spite of himself, to a Bavarian princess, a
political alliance intended to make an end of all dissensions between
the two states. From the first day of their union an unconquerable
estrangement and a constant coolness had sprung up between the
young couple, and consequently, at the fall of Napoleon, they were
divorced. The Princess Charlotte of Bavaria returned to her father’s
Court. Unappreciated by a husband whose affection she had been
unable to gain, she never uttered a word of reproach; her angelic
temper and her unalterable kindness never failed her. Later on, the
84
imperial crown of Austria was offered to her, and eventually she
shared one of the most powerful thrones of Europe. When her first
husband learnt the news of the unexpected elevation of the woman
he had neglected, but whose noble heart he had never misjudged,
he exclaimed, ‘I’ll have, at any rate, one more friend at the Court of
Vienna.’
Catherine of Russia and Wilhelm of Würtemberg both became
free. From that moment a mutual and strong affection took
possession of their hearts, which, constrained so long by the will of
others, had learnt to appreciate the delights of natural attraction.
How often in the shady glades of the Prater, or on the banks of the
majestic stream flowing at its foot, have I seen them, emancipated
for a little while from the etiquette of Courts, and yielding like
ordinary mortals to the feeling that animated them. Far from the
pomp and splendour of their ordinary surroundings, they perhaps
confidentially made plans for the future, in the hope of a union
which bade fair to be happy—the prince, young, manly, with a noble
disposition and reputed for his brilliant courage; the grand-duchess
conspicuous for her intellectual and physical grace. Now and again a
third came to interrupt this ‘dual solitude’; but his presence evidently
made no difference; for the third comer was not only a brother, but
a friend—no less a personage than Alexander himself, who appeared
to be supping full with glory and happiness.
The fête given by the czar in honour of his charming sister was
worthy in every respect of his brotherly affection and of its object.
All the sovereigns, all the illustrious guests of the Congress, had
repaired to it, and with him had come all the Russians of distinction:
Nesselrode, Gagarine, Dolgorouki, Galitzin, Capo d’Istria,
Narischkine, Souvaroff, Troubetzkoy, the two Volkonskis, Princesses
Souvaroff, Bagration, Gagarine, and many others equally remarkable
for their birth, wealth, beauty, and their distinguished manners.
Practically, I found myself among all those magnificent Muscovite
beings who had compelled my admiration at Moscow, St. Petersburg,
and at Tulczim, at the Comtesse Potocka’s, where the year seemed
to be made up of three hundred and sixty-five fêtes.
The rooms at Prince Razumowski’s were lighted with a profusion
that reminded one of the resplendent rays of the sun. A vast riding-
school had been converted into a ball-room; and to impart variety to
the entertainment, the corps de ballet of the Imperial Theatre had
organised a Muscovite divertissement, the minutest details of which
were carried out with scrupulous exactness. Towards the middle of
the ball, they made their appearance dressed as gipsies, and
performed dances with which those supposed descendants of the
Pharaohs enhance the fêtes of the rich and sensuous boyards. These
dances, in virtue of their graceful movements and the
picturesqueness of the postures, are, according to that great
traveller Griffiths, much superior to those of the bayadères of India.
The ball was opened by the inevitable and methodical polonaise.
The fête was, however, marked in particular by a Russian dance, by
one of the Court ladies of Empress Elizabeth and General Comte
85
Orloff, one of the aides-de-camp of Emperor Alexander. Both wore
the Russian dress, the comte that of a young Muscovite, namely, a
close-fitting caftan, tied round the waist by a cashmere scarf, a
broad-brimmed hat, and gloves like those of the ancient knights; his
partner was dressed like the women of Southern Russia, whose
costumes vie in richness with those of all other nations. On her
head, the hair arranged in flat bands in front and falling in long plaits
behind, she wore a tiara of pearls and precious stones. The
ornament harmonised perfectly with the rest of the costume,
composed, as usual, of exceedingly bright-coloured material.
This Russian dance is absolutely delightful, representing as it
does the pantomimic action of a somewhat impassioned courtship. It
is like the Galatea of Virgil. The performers acquitted themselves in
the most delightful manner, and were amply rewarded by the
enthusiastic applause of the spectators.
The Russian dance was followed by mazurkas, a kind of
quadrille, originally hailing from Massow. Among ball-room dances
none demand greater agility and none lend themselves to more
statuesque movements. In order that nothing might be wanting to
the magnificence of this fête, there was, in accordance with the
latest fashion in Vienna, a lottery. The prizes were many and
handsome to a degree. An apparently trivial circumstance lent an
unexpected interest to the proceedings. Custom had decreed that
each cavalier, if favoured by luck, should offer his prize to a lady. A
rich sable cape fell to the lot of the Prince of Würtemberg: he
immediately offered it to her in whose honour the entertainment was
given. Verily, he had his reward. Handsome Grand-Duchess
Catherine wore in her bosom a posy of flowers, fastened by a
ribbon. She unfastened it, and presented it to the donor of the cape.
The whole scene, which practically emphasised in public the
existence of a quasi-secret attachment, elicited murmurs of approval
and wishes for the young people’s happiness. ‘Hail to the future
Queen of Würtemberg,’ remarked Prince Koslowski to me; ‘queen
when it shall please the crowned Nimrod to vacate the place. In
reality, no crown will have ever graced a more beautiful brow.’ The
episode, and the conjectures to which it gave rise, added another
charm to this fête marked by so many.
The dancing had ceased, and the prince and I strolled through
the vast rooms of the palace, which might easily have been mistaken
for a temple erected to art, so numerous were the masterpieces
collected there by its owner. Here pictures by the greatest painters
of every school: Raphaels by the side of Rubenses, Van Dycks in
juxtaposition to Correggios; there, a library filled to overflowing with
most precious books and rare manuscripts; in a third spot a cabinet
containing most exquisite specimens of ancient art and modern
carving. The majority of the guests, however, seemed to prefer a
gallery set apart for the marvels of the sculptor’s chisel, among
which was some of the best handiwork of Canova. The gallery was
lighted by alabaster lamps, the soft glow of which seemed to throw
into relief the perfection of those statues apparently endowed with
life.
About two in the morning they threw open the huge supper-
room, lighted by thousands of wax candles. It contained fifty tables,
and by that alone the number of guests might be estimated. Amidst
banks of flowers was displayed all that Italy, Germany, France, and
Russia had to offer in the way of rare fruit and other edibles: such as
sturgeon from the Volga, oysters from Ostend and Cancale, truffles
from Périgord, oranges from Sicily. Worthy of note was a pyramid of
pine-apples, such as had never before been served on any board,
and which had come direct from the imperial hothouses at Moscow
for the czar’s guests. There were strawberries all the way from
England, grapes from France, looking as if they had just been cut
from the trailing vine. Still more remarkable, on each of the fifty
tables there stood a dish of cherries, despatched from St.
Petersburg, notwithstanding the December cold, but at the cost of a
silver rouble apiece. Regarding these events many years after their
occurrence, I am often tempted to mistrust to a certain extent my
recollections of all this lavish display.
This fête, which really deserved precedence among all the daily
pomp and splendour of the Congress, was prolonged till dawn, when
a breakfast was served and dancing was resumed. Only the need of
rest made us regretfully bend our steps homeward and leave that
magnificent palace where so many fair women and brave men had
forgathered in the pursuit of pleasure.
Many years have gone by since that memorable night. The
charming woman in whose honour the fête was given became the
Queen of Würtemberg. Death claimed her prematurely as his victim.
The Prince Koslowski, who had been, like myself, an eye-witness of
that charming love-episode at Vienna, and who was subsequently
despatched as ambassador to her Court, saw her die of the same
disease that carried away her brother, the emperor. And only a short
86
time ago the son of Marie-Louise and the Comte de Neipperg
married the daughter of this Catherine of Russia who had been
asked in marriage by Napoleon. How very truly Shakespeare
exclaims: ‘There are more things in heaven and earth, Horatio, than
are dreamt of in your philosophy.’
As for me, when my thoughts go back to that period of
happiness and freedom from care called the Congress of Vienna, I
always picture to myself sweet Catherine, not amidst all those fêtes,
but strolling in the dusky glades of the Prater, where I so often saw
her, proud of her love for the Prince Royal of Würtemberg and of her
tender affection for her brother.
CHAPTER XI
The Last Love-Tryst of the Prince de Ligne—A Glance at the
Past—Z——or the Consequences of Gaming—Gambling in
Poland and in Russia—The Biter Bit—Masked Ball—The
Prince de Ligne and a Domino—More Living Pictures—
The Pasha of Surêne—Two Masked Ladies—Recollections
of the Prince de Talleyrand.

I had spent the evening at the theatre of the Carinthian Gate,


and was returning home by way of the ramparts, confident of
meeting no one whom I knew; for on that night, in spite of the
many strangers in Vienna and the multitude of fêtes, everything was
unusually quiet long before midnight. It was magnificent weather for
the time of the year. In the recess of a bastion jutting over the dry
moat, I noticed a lank figure wrapped in a white cloak, which might
easily have passed for that of Hamlet. Impelled by curiosity, I drew
nearer, and to my utter astonishment recognised the Prince de
Ligne.
‘What in Heaven’s name are you doing here, prince, at this hour
of the night and in the biting cold?’
‘In love affairs the beginning only is delightful; consequently, I
always find great delight in recommencing. At your age, though, it
was I who kept them waiting; at mine they keep me waiting; and,
what’s worse, they don’t come.
‘I am keeping an appointment, but as you can see for yourself, I
am keeping it alone. Well, people forgive hunchbacks the
exuberance of their dorsal excrescence; why, at my age, should not
people forgive my exuberance?’
‘If it be true that woman’s happiness consists in the reflection of
a man’s glory, where is the woman who would not be proud to owe
hers to you?’
The prince shook his head, and declaimed mock-tragically:
‘“No, no; all things flee as age approaches,
All things go, illusion too:
Nature would have done much better
To keep that until the last.”’

‘I’ll leave you to your appointment, prince,’ I said.


‘No, I’ll wait no longer; lend me your arm and take me home.’
We slowly went in the direction of his house, and on the way his
conversation betrayed the feeling of slighted pride; his words were
marked by a tinge of melancholy which was new to me.
‘I am inclined to believe that in life reflection comes as a last
misfortune,’ he said. ‘Up to the present I have not been among those
who think that growing old is in itself a merit. At the dawn of life
love’s dream balances its illusions on the spring within us. One
carries the cup of pleasure to one’s lips; one imagines it’s going to
last for ever, but years come, time flies and delivers its Parthian
darts; from that moment disenchantment attends everything, the
colours fade out of one’s existence. Ah me, I must get used to the
idea.’
‘But, prince, you attach too much importance to a trifling
disappointment. You must put it down to the exactions of society,
which those who are in it cannot always disregard.’
‘No, no, there’s an end of my illusions; everything warns me of
the years accumulating behind me. I am no longer considered good
for anything. In days gone by, at Versailles, I was consulted on this,
that, and the other, on balls, fêtes, theatres, and so forth. At present

You might also like