100% found this document useful (6 votes)
34 views

MATLAB Programming with Applications for Engineers 1st Edition Chapman Solutions Manualpdf download

The document provides links to various MATLAB solutions manuals and test banks for different editions of engineering and mathematics textbooks. It includes a detailed explanation of user-defined functions in MATLAB, highlighting the differences between script files and functions, as well as the pass-by-value scheme. Additionally, it presents example functions for sorting arrays and performing trigonometric operations in degrees.

Uploaded by

cusbanuor
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 (6 votes)
34 views

MATLAB Programming with Applications for Engineers 1st Edition Chapman Solutions Manualpdf download

The document provides links to various MATLAB solutions manuals and test banks for different editions of engineering and mathematics textbooks. It includes a detailed explanation of user-defined functions in MATLAB, highlighting the differences between script files and functions, as well as the pass-by-value scheme. Additionally, it presents example functions for sorting arrays and performing trigonometric operations in degrees.

Uploaded by

cusbanuor
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/ 52

MATLAB Programming with Applications for

Engineers 1st Edition Chapman Solutions Manual


pdf download

https://testbankfan.com/product/matlab-programming-with-
applications-for-engineers-1st-edition-chapman-solutions-manual/
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/

Essentials of MATLAB Programming 3rd Edition Chapman


Solutions Manual

https://testbankfan.com/product/essentials-of-matlab-
programming-3rd-edition-chapman-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/

Managerial Accounting 2nd Edition Hilton Solutions


Manual

https://testbankfan.com/product/managerial-accounting-2nd-
edition-hilton-solutions-manual/
International Economics 11th Edition Salvatore Test
Bank

https://testbankfan.com/product/international-economics-11th-
edition-salvatore-test-bank/

Freedom on My Mind Volume 2 A History of African


Americans with Documents 2nd Edition White Test Bank

https://testbankfan.com/product/freedom-on-my-mind-
volume-2-a-history-of-african-americans-with-documents-2nd-
edition-white-test-bank/

College Algebra Enhanced with Graphing Utilities 7th


Edition Sullivan Solutions Manual

https://testbankfan.com/product/college-algebra-enhanced-with-
graphing-utilities-7th-edition-sullivan-solutions-manual/

Physics of Sports 1st Edition Lisa Solutions Manual

https://testbankfan.com/product/physics-of-sports-1st-edition-
lisa-solutions-manual/

Ratio and Proportion Dosage Calculations 2nd Edition


Giangrasso Test Bank

https://testbankfan.com/product/ratio-and-proportion-dosage-
calculations-2nd-edition-giangrasso-test-bank/
Biochemistry Concepts and Connections 1st Edition
Appling Solutions Manual

https://testbankfan.com/product/biochemistry-concepts-and-
connections-1st-edition-appling-solutions-manual/
6. 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

139
© 2013 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
% ==== ========== =====================
% 07/03/11 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

140
© 2013 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
% ==== ========== =====================
% 07/03/11 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');

% Display the sorted result.


141
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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
2.0000
5.0000

142
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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 ==> d:\book\matlab\soln\Ex5.4\test_ssort1.m


On line 66 ==>

6.5 A set of functions to perform trigonometric operations in degrees are 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
% ==== ========== =====================
% 07/03/11 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
% ==== ========== =====================
% 07/03/11 S. J. Chapman Original code

% Check for a legal number of input arguments.


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

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

143
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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
% ==== ========== =====================
% 07/03/11 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
% ==== ========== =====================
% 07/03/11 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:
% Date Programmer Description of change
% ==== ========== =====================
% 07/03/11 S. J. Chapman Original code

% Check for a legal number of input arguments.


144
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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
% ==== ========== =====================
% 07/03/11 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
% ==== ========== =====================
% 07/03/11 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:

% Script file: test_functions.m


%
% Purpose:
% To perform a median filter on an input data set.
%
145
© 2013 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
% ==== ========== =====================
% 07/03/11 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
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
146
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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
% ==== ========== =====================
% 07/03/11 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)
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
147
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% %
% 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
% ==== ========== =====================
% 07/03/11 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)

% 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:

148
© 2013 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
% ==== ========== =====================
% 07/03/11 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 we can 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
% ==== ========== =====================
% 07/03/11 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.

1 Later we will learn about function varargin, which can support any number of arguments.
149
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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)


area =
100.00
>> area = area_polygon(10,0,8,8,2,10,-4,5)
area =
43.00

150
© 2013 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.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
% ==== ========== =====================
% 07/03/11 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 =
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
151
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% 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
% ==== ========== =====================
% 07/03/11 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:
% 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
%
152
© 2013 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:
% data1 -- Array to sort
% data2 -- Copy of array to sort
% elapsed_time1 -- Elaosed time for ssort
% elapsed_time2 -- Elaosed 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 = 118.288
Sort time using sort = 0.013641

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.

Note that the sort time for the selection sort increases as the square of the number of values
sorted. This may make it impossible to do the calculation for 1,000,000 samples, as specified in
the original problem. This will be modified to 200,000 samples in subsequent printings.

% Script file: compare_sorts.m


%
% Purpose:
% To compare the sort function from Example 6.2 and the
% built-in MATLAB sort
%
% Record of revisions:

153
© 2013 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
% ==== ========== =====================
% 07/04/11 S. J. Chapman Original code
%
% Define variables:
% data1 -- Array to sort
% data2 -- Copy of array to sort
% elapsed_time1 -- Elaosed time for ssort
% elapsed_time2 -- Elaosed 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;

% Display the relative times


disp(['Sort time for ' int2str(nsamp) ' using ssort = '
num2str(elapsed_time1)]);
154
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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)]);

When this program is executed, the results are:

>> compare_sorts
Sort time using ssort = 118.288
Sort time using sort = 0.013641

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

>> compare_sorts
Sort time for 10000 using ssort = 1.2153
Sort time for 10000 using sort = 0.0013928
Sort time for 100000 using ssort = 137.3888
Sort time for 100000 using sort = 0.013531
Sort time for 200000 using ssort = 631.6224
Sort time for 200000 using sort = 0.026963

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:

155
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% 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/10 S. J. Chapman Original code
% 1. 07/04/11 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:

156
© 2013 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) -- 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)
% 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/10 S. J. Chapman Original code
% 1. 07/04/11 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

157
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
% and 6.

% Define variables:
% result -- Resulting integer

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 07/04/11 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
% ==== ========== =====================
% 07/04/11 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.

158
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
hist(result,6);
title('\bfHistogram of values returned from function "dice"');
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.

159
© 2013 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:
% fact -- k! (k-factorial)
% result -- Resulting value from distribution

% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 07/07/11 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
% ==== ========== =====================
% 07/07/11 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:']);

160
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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');
xlabel('\bfValue');
ylabel('\bfProbability');

When this program is executed, the results are a 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)

161
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
%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
% ==== ========== =====================
% 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))/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
% ==== ========== =====================
% 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))/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
162
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
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:
% To plot the hyperbolic functions sinh, cosh, abd tanh.
%
% Record of revisions:
% Date Programmer Description of change
% ==== ========== =====================
% 07/12/11 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:

163
© 2013 Cengage Learning. All Rights Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part.
Random documents with unrelated
content Scribd suggests to you:
Cassiterite
Cassiterite, tin dioxide, is the mineral that serves as the chief source
of tin. Tin does not corrode and tarnish, and one of its main uses is in
the making of tin cans. (Actually, our tin cans are made from thin
sheets of steel that have been coated with a protective layer of tin.)

Cassiterite has either a nonmetallic or a submetallic luster. Some


specimens are brilliant and shiny; others are dull. Cassiterite may be
translucent to transparent. It may be black, brown, gray, reddish
brown, or yellowish brown. When rubbed across a streak plate, this
mineral leaves a pale brown, a pale yellow, or a white streak.
Cassiterite is quite heavy—it has a specific gravity of 6.8 to 7.1. It is
too hard to be scratched by an average pocket knife.

Sometimes, prospectors use a chemical test to help them identify


cassiterite. They put small pieces of metallic zinc into a jar or test
tube containing dilute hydrochloric acid. Then they add a few
fragments of the mineral that they suspect is cassiterite. If the
fragments are cassiterite, they become covered with a pale gray
coating of metallic tin.

Cassiterite’s most common crystal shape is a short, 8-sided 48


prism with pyramids at each end, but perfect crystals are not
often found. Most Texas cassiterite does not show a crystal shape.
Instead, it occurs as crystalline masses in igneous rocks and as loose
pebbles that have weathered out of these rocks.

Cassiterite occurs in a number of places in the United States but not


in large quantities. A small amount of cassiterite has been found in
quartz veins in Precambrian granite in both central Texas and west
Texas. In El Paso County, the cassiterite is found on the east side of
the Franklin Mountains a few miles north of El Paso, where some of it
has been mined. In central Texas, cassiterite occurs in the Streeter
area of Mason County.
When the granite rocks in these areas were formed, probably not all
of the hot magmas cooled and hardened at the same time. The fluids
given off by the remaining magmas contained tin and several other
elements. It is believed that these fluids moved up into cracks in the
granite rocks and formed the cassiterite.

Celestite
Celestite is a strontium sulfate mineral. It is colorless, white, yellow,
or gray. Light blue specimens of this mineral also are found, and it is
because of this sky-like color that celestite gets its name. The word
celestite comes from the Latin word caelestis, meaning of the sky.

Celestite has a glassy to a pearly luster, and it is either transparent or


translucent. It gives a white streak when rubbed across a streak
plate. Celestite has a specific gravity of 3.95 to 3.97. It is, however,
lighter than barite, a mineral that it resembles. Celestite is not very
hard—a knife will scratch it, although your fingernail will not. It
cleaves in three directions, and some of the fragments are flat and
slabby.
Celestite cleavage fragment from Lampasas County, Texas.

Celestite occurs commonly either as prism-shaped or flat 49


crystals and as cleavable, granular, or fibrous crystalline
masses. In Texas, it is found in geodes, as rounded nodules, or as
bedded or layer-like deposits in limestones and other sedimentary
rocks. In Real County, celestite occurs on the walls of a cave in
Cretaceous limestone.

Some celestite may be deposited by sea water, but much of the Texas
celestite is believed to have been deposited by underground water
that seeped through cracks and pores in the limestones and other
sedimentary rocks. This water picked up and dissolved strontium
compounds that were scattered in small amounts through the rocks.
Then, it re-deposited the strontium in the rocks as celestite.

In Texas, beds of celestite occur in Permian rocks in Coke, Fisher, and


Nolan counties and in Lower Cretaceous rocks in Brown, Comanche,
and Mills counties. Celestite geodes and nodules are found in Lower
Cretaceous limestone rocks in Lampasas, Travis, and Williamson
counties, and in Permian rocks in Coke, Fisher, Nolan, and Taylor
counties.

Celestite is one of two minerals (the other mineral is strontianite,


strontium carbonate) used as a source of strontium. Strontium
compounds give a crimson-red color to a flame, so they are used in
fireworks, tracer bullets, and flares. Perhaps you have seen a red
flare set out on the highway at night to warn motorists that a truck
has stalled. The chances are good that the flare’s red flame was due
to a strontium compound. Some of the Texas celestite has been
mined, but most of the strontium minerals now used in the United
States are imported from England and Mexico.

Cerargyrite. See Silver Minerals.

Chalcedony. See Quartz.

Chalcocite. See Copper Minerals.

Chalcopyrite. See Copper Minerals.

Chalk. See Limestone.

Chert (Flint). See Quartz.


Chrysotile. See Asbestos; Serpentine.

Cinnabar
Cinnabar, which is mercuric sulfide, is the most common mercury
mineral. It has a dark red or a bright yellowish-red color and is
transparent to translucent. When rubbed across a streak plate, it
leaves a dark red streak. If pure, cinnabar has a brilliant, shiny,
nonmetallic luster. It is, however, commonly found mixed with
impurities, such as clay, calcite, iron oxide, or bituminous material,
and then it looks dull and earthy. Cinnabar is quite heavy—it has a
specific gravity of 8.10. It is rather soft, and you can scratch it with a
copper penny.

Some prospectors use a quick chemical test to identify cinnabar. They


rub a clean, shiny copper coin with a mineral sample that has been
moistened with a drop or two of dilute hydrochloric acid. If the
sample is cinnabar, a light silvery-gray coating appears on the coin.

Cinnabar occurs as small crystals or as fine-grained or compact


crystalline masses. It is found in veins that fill cracks in rocks and
also occurs as crusts and coatings on rocks. It also may be widely
scattered through rocks, such as limestones.

Cinnabar occurs in the Terlingua area of Brewster and Presidio


counties in west Texas. It has been mined there, off and on, since
about 1894, and during this time, mercury worth many millions of
dollars has been produced.

Most of this west Texas cinnabar is found in cracks, pores, and


breccia-filled cavities of Cretaceous limestones and clays. If you will
look at the Texas geologic map (pp. 4-5), you will see that igneous
rocks occur in this district. Many millions of years ago during the
Tertiary Period, when these igneous rocks were still hot magma,
some of them pushed up under the Cretaceous rocks and emitted
fluids containing mercury. The fluids moved upward through cracks
and pores in the Cretaceous rocks where they deposited the 50
mercury as cinnabar and as other mercury minerals.

Cinnabar crystals (dark) with calcite crystals (white) from the Terlingua
area of Brewster County, Texas.

Mercury is an unusual element. Instead of occurring as a solid metal


at ordinary room temperatures, as do gold, silver, and lead, it remains
a liquid until it is cooled to 38 degrees below zero Fahrenheit.
Because the silvery little drops of liquid mercury roll about as if they
were alive, this element long has been called quicksilver.
Mercury is used in a variety of ways. In some noiseless light-switches,
a glass tube containing a small ball of mercury tilts when the switch
is turned “on.” The mercury then rolls to the end of the tube that
contains electrical contacts and quietly completes the electrical
circuit. In other uses, mercury is added to silver, tin, and other metals
to make fillings for teeth. Some medicines, such as calomel and
mercurochrome, contain mercury. Fulminate of mercury helps to set
off dynamite and other explosives. Mercury is used in many
barometers and thermometers, and farmers use mercury poisons to
control insects and fungi.

Mercury also commonly is used to obtain gold from its ores. 51


One method of accomplishing this is to pass wet gold-bearing
gravel or crushed rock over metal plates that are coated with
mercury. The gold particles quickly mix with the mercury to form an
amalgam, which later can be scraped off the plates. The gold is then
recovered by heating the amalgam to drive off the mercury.

Clay
Clay is a smooth, soft, earthy rock made up of mineral particles no
bigger than specks of dust. Some of the particles are clay minerals,
which consist of aluminum, silicon, and other elements. In addition,
tiny particles of quartz, calcite, and other minerals may also be
present in the clay.

The clay particles are all that remain of rocks and of minerals, such
as feldspar, that have been broken into fragments or altered into clay
minerals by weathering. Some clay remains at the place where it
formed, but some is carried away and deposited elsewhere.

Clay is white, tan, brown, red, green, blue, gray—almost any color.
When moist, it has an earthy odor. You can moisten a piece of clay
enough to notice this just by breathing on it. Most clays, when wet,
can be molded into many different shapes—that is, they are plastic,
but when they are dry, they are firm and solid.

Clay is abundant in Texas and has a number of uses. Some goes to


make portland cement, and some is baked or burned in a kiln to
make brick, tile, sewer pipes, pottery, and other products. This kind
of clay is obtained from Tertiary formations of the Gulf Coastal Plain,
from Upper Cretaceous formations in central Texas, and from
Pennsylvanian formations in north-central Texas. (You can locate
Tertiary, Cretaceous, and Pennsylvanian rocks on the Texas geologic
map, pp. 4-5.)

A special kind of white burning clay that can be used to make


chinaware is called kaolin or china clay. It contains particles of the
clay mineral kaolinite as well as several other clay minerals. Deposits
of china clay occur in southern Jeff Davis County and in Real County
near Leakey, but none is being produced.

Another kind of clay, bentonite, forms from weathered volcanic ash.


Bentonite contains the clay mineral montmorillonite and looks smooth
and soap-like. Fresh samples of this clay are white, pale green, or
pale blue, but dried-out or weathered samples are tan, brown,
yellow, or reddish. When wet, bentonite absorbs water, swells, and
then has a jelly-like appearance.

Surface deposits of bentonite occur chiefly in Eocene Tertiary


formations of the Gulf Coastal Plain, in Cretaceous formations of the
Big Bend area of west Texas, and in Quaternary formations of the
High Plains.
Bentonite is used as a drilling-fluid additive in the rotary method of
drilling for petroleum and gas.

Some bentonite is used to absorb unwanted coloring material in


petroleum and in vegetable oils. It is then known as a bleaching clay.
Bentonite bleaching clay is obtained from some of the Tertiary
formations along the Texas Gulf Coastal Plain. It has been 52
produced in Angelina, Fayette, Gonzales, Jasper, Walker, and
other counties in this area.
Another important use of bentonite, and of other clay, too, is as
drilling mud. In the rotary method of drilling for oil and gas, mud is
pumped down into the drilled hole. This mud carries the rock cuttings
up to the surface, it cools the drilling tools, and it coats and seals the
walls of the hole. Along the Gulf Coastal Plain, drilling clay is obtained
from Tertiary formations.

Common Opal. See Opal.

Copper Minerals (Chalcocite, Chalcopyrite,


Malachite, Azurite)
A number of minerals containing copper, such as chalcocite,
chalcopyrite, malachite, and azurite, occur in small deposits in Texas.
They are found chiefly in the Llano uplift area of central Texas, in the
Van Horn area of Culberson and Hudspeth counties in west Texas,
and in a group of counties in north-central Texas.

Copper is an important element. Because it is an unusually good


conductor of electricity (only silver, which costs much more, is a
better one), it is used for many kinds of wires for switchboards,
generators, motors, telephone and telegraph equipment, and light
and power lines.

Manufacturers commonly combine copper with other elements. For


example, some copper is mixed with zinc to make brass and with tin
and a little zinc to make bronze. These mixtures are called alloys.
Many products are made from copper alloys, including tubing, pipes,
jewelry, pots, and pans. Even our coins contain copper.

Sometimes, a prospector uses a chemical test to find out if copper is


present in a mineral. First, he crushes a small sample of what he
believes is a copper mineral (such as chalcocite, chalcopyrite, azurite,
or malachite). He then puts the sample in a glass jar or test tube and
pours in a small amount of dilute nitric acid (this acid, like
hydrochloric acid, is poisonous). After the sample has dissolved in the
acid, he adds enough ammonium hydroxide to make the solution
alkaline. If the sample is a copper mineral, the solution turns a deep-
blue color.

One of the copper minerals, chalcocite, copper sulfide, also is known


as copper glance. It is a metallic mineral that commonly tarnishes to
a dull black. By chipping off a fragment to obtain a fresh surface, you
will see that it has a shiny lead-gray color. Chalcocite is rather soft,
and it is sectile, that is, a knife will cut through it as well as scratch it.
When you rub chalcocite across a streak plate, it gives a grayish-
black streak. This mineral commonly occurs as compact masses or as
granular masses.

Chalcocite, with its dark color, does not look at all like copper, which
is a bright reddish brown. Chalcocite, however, is the chief copper
mineral at the most important copper mine in Texas, the Hazel mine,
which is about 15 miles northwest of Van Horn in Culberson County
in west Texas. This mine, although now idle and almost filled with
water, has produced about one and a half million pounds of copper
along with more valuable silver ores. Here, the chalcocite and other
minerals occur in material that fills large cracks in red sandstone of
the Precambrian Hazel Formation. It is thought that long ago, molten
igneous rock material far below the surface sent out hot solutions
containing copper and other elements. These solutions moved
upward and deposited minerals in the fracture zone in the sandstone.

Chalcocite occurs also in north-central Texas. It is found in Archer,


Baylor, Clay, Foard, Hardeman, King, Knox, Stonewall, and several
other counties of this area. Here, it occurs in Permian sedimentary
rocks (called “red beds”) as rounded masses, as scattered grains, and
as petrified wood. Because these deposits are far from any igneous
rocks, they apparently did not form in the same way as those at the
Hazel mine. These north-central Texas deposits have never really
been commercially developed. During the Civil War, however, some
copper from this area was made into percussion caps for the
Confederacy.

53

The Hazel copper-silver mine, Culberson County, Texas, as it appeared in


1951. Photograph by P. T. Flawn.

Another copper mineral, chalcopyrite, is a copper-iron sulfide. It also


is known as copper pyrites and yellow copper ore. This mineral has a
metallic luster and a brass-yellow or a golden-yellow color. When
rubbed across a streak plate, it gives a greenish-black streak.
Chalcopyrite will tarnish and then has bronze, blue, purple, and other
rainbow-like colors. This mineral is fairly soft—you can scratch it with
a pocket knife. Because of chalcopyrite’s yellow color, it has often
been mistaken for gold. For this reason, it, like iron pyrite, is often
called fool’s gold. (See Gold, p. 60, for ways to tell them apart.)
Chalcopyrite commonly is found in compact masses that show no
crystal shapes. These masses either are scattered through rocks or
occur in material that fills cracks in rocks.

Some chalcopyrite is found in Precambrian sandstone at the Hazel


mine and in other deposits in the Van Horn area of Culberson and
Hudspeth counties. It also occurs in Precambrian rocks at the
Sheridan and Pavitte prospects in Burnet County. These chalcopyrite
localities are in districts where igneous rocks occur.

It is likely that, long ago, hot solutions containing copper moved


upward, out of deeply buried molten magma. While still far below the
surface, the solutions deposited the chalcopyrite in cracks and other
openings in the nearby rocks.

Two copper minerals of Texas, azurite and malachite, are copper


carbonates. Azurite is commonly called chessylite and blue copper;
malachite is called green copper carbonate. Because these minerals
are carbonates, a drop of dilute hydrochloric acid will fizz and bubble
when placed on either of them.

Azurite has a bright, intense blue color and leaves a blue streak when
rubbed across a streak plate. Malachite has a bright green color and
leaves a green streak. These minerals have a nonmetallic luster and a
glassy to dull appearance. Commonly, they are translucent, although
some specimens of azurite are transparent. Both azurite and
malachite are fairly soft—a pocket knife will scratch them, but a
copper penny will not.

Azurite and malachite occur as individual crystals, but you are 54


more likely to find them as crusts on rocks and on other
minerals. Malachite is also found in rounded fibrous masses that
resemble bunches of grapes (described then as botryoidal).

Both azurite and malachite are formed in the same way. Underground
waters seep through rocks that contain deposits of copper minerals
(such as chalcocite and chalcopyrite) and cause chemical reactions
which change these minerals into malachite and azurite.

Malachite is more plentiful than azurite, but both minerals can be


found together. You can expect to find at least one of them at the
same localities where chalcocite, chalcopyrite, and other copper
minerals occur.

Coquina. See Limestone.

Diatomite. See Opal.

Dolomite
Dolomite is the name given both to a rock and to a mineral. The
mineral is a calcium-magnesium carbonate and has a glassy or a
pearly luster. It is any of a number of colors, such as white, pink,
brown, or gray, or it can be colorless. Dolomite leaves a white streak
on a streak plate and is transparent to translucent. It is not
particularly hard and can be scratched with a pocket knife, although
not with a copper penny. Dolomite cleaves perfectly in three
directions, and some of the cleavage fragments are rhombohedrons.
However, the cleavages of the individual mineral grains in specimens
of fine-grained massive dolomite are not readily distinguishable.
Dolomite rock from the vicinity of Fairland, Burnet County, Texas.

Most Texas dolomite occurs as coarse-, medium-, and fine-grained


crystalline masses as the chief mineral in dolomite rock and in
dolomitic marble. It is also found as 6-sided crystals that are rhomb-
shaped; when the faces are curved, they have a saddle-like
appearance.

Crystals of the mineral dolomite commonly occur in cavities in the


dolomite rocks. It is believed that they were deposited there by
seeping underground waters. The waters dissolved some of the
dolomite in the rocks and then re-deposited it as crystals.

Dolomite rock is made up mostly of crystalline grains of the mineral


dolomite. In addition, quartz grains, calcite, and other minerals may
be present. Dolomite rock is almost any color—white, buff, pink
brown, gray. It resembles some limestone, and these two rocks
actually are closely related.

To help tell them apart, dilute hydrochloric acid often is used. A few
drops of this acid will readily fizz and bubble if the rock you put them
on is a limestone. If the rock is dolomite, the acid will effervesce only
very little or not at all. (If, however, the acid is put on powdered
dolomite, it then will fizz readily.) Dolomite is slightly harder than
limestone, and it also is slightly heavier.

Some dolomite rocks formed directly from materials that were


dissolved in sea water, and others are altered limestone rocks. Some
limestones altered into dolomite on the sea floor by the addition of
magnesium from the sea water. Others changed into dolomite much
later after the sea had withdrawn and the limestones had become a
part of the land; underground waters containing magnesium seeped
through these limestones and altered them into dolomite. 55

Many of the dolomite rocks are found with limestones. In Texas they
occur mostly in Cambrian, Ordovician, Mississippian, Pennsylvanian,
Permian, and Cretaceous formations. The geologic map (pp. 4-5)
indicates where these strata appear at the surface in Texas.

Dolomite is abundant in the Llano uplift area of central Texas—


particularly in the Cambrian and Ordovician rocks. A number of these
central Texas dolomites have been quarried for use as building
stones. Some of them also have been crushed and used as a road-
building material and as a stone aggregate that is mixed with cement
to make concrete. This dolomite is also used as terrazzo chips
(terrazzo floors are described with serpentine on p. 88). In addition,
Ellenburger (Ordovician) dolomite from Burnet County was used
during World War II as a source of the lightweight metal magnesium.

Dravite. See Tourmaline.


Feldspar
Feldspar is the name given to a group of nonmetallic minerals that
are much alike. Several of them are so similar that a petrographic
microscope must be used to tell them apart. Each of the feldspar
minerals is an aluminum silicate. Each of them contains, in addition,
at least one of the following elements: potassium, sodium, calcium,
and barium. The feldspar minerals that are found in Texas include
albite, a sodium-aluminum silicate, and orthoclase and microcline,
which are both potassium-aluminum silicates.

The feldspar minerals are transparent to translucent and have either


glassy or pearly lusters. They can be white, cream, or a shade of red,
brown, yellow, blue, gray, or green. When you rub a feldspar across a
streak plate, it leaves a white streak. The feldspars are rather hard—a
pocket knife will not scratch them, although a piece of quartz or a
steel file will. These minerals have good cleavage in two directions.
The cleavages meet at an angle of about 90°, so that the cleavage
fragments have square corners.
Feldspar cleavage fragment from Llano County, Texas. The two directions
of good cleavage meet at an angle of about 90°.

The feldspars are important rock-forming minerals. You can find them
in igneous rocks, such as granite or pegmatite, and in metamorphic
rocks, such as gneiss. They also occur as fragments in sedimentary
rocks, such as some sandstone and conglomerate.

Although the feldspars can originate in other ways, they form mostly
from hot magmas that cool and crystallize into igneous rocks. These
minerals occur in the rocks as grains, as cleavable masses, and as
individual crystals. The crystals may be shaped like prisms, or they
may be flat and slabby.
Good places to look for feldspars are in areas where granites,
pegmatites, and other intrusive igneous rocks appear at the surface.
The pegmatite rocks of Burnet, Gillespie, Llano, and Mason counties
in the Llano uplift area of central Texas, and those of the Van Horn
Mountains in Hudspeth and Culberson counties in west Texas, are
especially good sources of feldspar. Large cleavable masses and
crystals that are more than a foot long are found in some of these
rocks.

The feldspars have a number of uses. Some of the pegmatite


feldspars from Llano County in central Texas have been crushed and
used as granules for built-up and composition roofs. In 56
addition, some have been shipped to Mexico for glass-making.
Some of the other uses of feldspar are in making porcelain, ceramic
glazes, and scouring compounds. A few of the feldspar minerals, such
as the variety of microcline known as amazonstone, are used as
gemstones.
Microcline feldspar crystals from near Granite Shoals Lake, Llano County,
Texas.

Fibrous Gypsum. See Gypsum.

Flint. See Quartz.

Fluorite
Fluorite is calcium fluoride. The fluorite that is mined and sent to
market, however, commonly is found mixed with quartz, calcite,
limestone, or other rocks and minerals. Industry calls this mixture
fluorspar.
Fluorite is a transparent to translucent mineral that has a glassy
luster. It may be colorless, or it may be white, pink, green, purple,
brown, or blue. Some specimens show more than one color. When
you rub fluorite across a streak plate, it leaves a white streak. This
mineral is not particularly hard—a pocket knife will scratch it,
although a copper penny will not. Fluorite has perfect cleavage in
four directions. By carefully breaking a specimen, you can obtain
cleavage fragments that are shaped like octahedrons.

Fluorite occurs as cleavable masses, as fine or coarse grains, and as


crystals. Most of the crystals are cubes, but some may be
octahedrons, dodecahedrons, or combinations of these.

Fluorite has been found both in west Texas and in central Texas. In
the Llano uplift area of central Texas, it occurs in a number of
Precambrian granite, pegmatite, schist, and gneiss rocks. The most
important, although small, deposit in this area is near Spring Creek a
few miles west of Burnet in Burnet County. Here, prospectors have
dug holes and pits in gneiss and schist rocks and found layers of
fluorite in them.

The largest known fluorite deposits in Texas (they are not particularly
large when you compare them with the deposits in Illinois and
Kentucky) are those in the Eagle Mountains of Hudspeth County. This
fluorite occurs in both igneous and sedimentary rocks. Many years
ago, probably during the late part of the Tertiary Period, hot magma
far below the surface gave off liquids and gases containing fluorine.
These fluids moved up through large cracks (called faults) in 57
Cretaceous limestones and Tertiary igneous rocks and
deposited fluorite in them. In places, beds of limestone have been
replaced by fluorite. Some of this west Texas fluorite has been mined
and shipped to market.
Fluorite has octahedral cleavage. The four directions of perfect cleavage
can result in cleavage fragments that are octahedrons.

Fluorite is extremely important as a flux in steel-making to help the


ingredients of the molten steel blend together. In addition, it
combines with sulfur, phosphorus, and other unwanted substances so

You might also like