for Engineers and Scientists
Fourth Edition
Brian H. Hahn
Daniel T. Valentine
AMSTERDAM • BOSTON • HEIDELBERG • LONDON
NEW YORK • OXFORD • PARIS • SAN DIEGO
SAN FRANCISCO • SINGAPORE • SYDNEY • TOKYO
Academic Press is an imprint of Elsevier
,Academic Press is an imprint of Elsevier
30 Corporate Drive, Suite 400, Burlington, MA 01803, USA
Linacre House, Jordan Hill, Oxford OX2 8DP, UK
Copyright © 2010, Daniel T. Valentine. Published by Elsevier Ltd. All rights reserved.
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission.
The MathWorks does not warrant the accuracy of the text or exercises in this book.
This book’s use or discussion of MATLAB® software or related products does not
constitute endorsement or sponsorship by The MathWorks of a particular pedagogical
approach or particular use of the MATLAB® software.
No part of this publication may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, electronic, mechanical, photocopying,
recording, or otherwise, without the prior written permission of the publisher.
Permissions may be sought directly from Elsevier’s Science & Technology Rights
Department in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333,
E-mail: . You may also complete your request online via
the Elsevier homepage (http://www.elsevier.com), by selecting “Support & Contact”
then “Copyright and Permission” and then “Obtaining Permissions.”
Library of Congress Cataloging-in-Publication Data
A catalog record for this book is available from the Library of Congress.
British Library Cataloguing-in-Publication Data
A catalogue record for this book is available from the British Library.
ISBN: 978-0-12-374883-6
For information on all Academic Press publications
visit our Web site at www.elsevierdirect.com
Typeset by: diacriTech, India
Printed in Canada
09 10 11 12 13 10 9 8 7 6 5 4 3 2 1
, Preface
The main reason for a fourth edition of Essential MATLAB for Engineers and
Scientists is to keep up with MATLAB, now in its latest version (7.7 Version
2008B). Like the previous editions, this one presents MATLAB as a problem-
solving tool for professionals in science and engineering, as well as students in
those fields, who have no prior knowledge of computer programming.
In keeping with the late Brian D. Hahn’s objectives in previous editions,
the fourth edition adopts an informal, tutorial style for its “teach-yourself”
approach, which invites readers to experiment with MATLAB as a way of dis-
covering how it works. It assumes that readers have never used this tool in their
technical problem solving.
MATLAB, which stands for “Matrix Laboratory,” is based on the concept of
the matrix. Because readers will be unfamiliar with matrices, ideas and con-
structs are developed gradually, as the context requires. The primary audience
for Essential MATLAB is scientists and engineers, and for that reason certain
examples require some first-year college math, particularly in Part 2. However,
these examples are self-contained and can be skipped without detracting from
the development of readers’ programming skills.
MATLAB can be used in two distinct modes. One, in keeping the modern-
age craving for instant gratification, offers immediate execution of statements
(or groups of statements) in the Command Window. The other, for the more
patient, offers conventional programming by means of script files. Both modes
are put to good use here: the former encouraging cut and paste to take full advan-
tage of Windows’ interactive environment; the latter stressing programming
principles and algorithm development through structure plans.
Although most of MATLAB’s basic (“essential”) features are covered, this book is
neither an exhaustive nor a systematic reference. This would not be in keeping
with its informal style. For example, constructs such as for and if are not
always treated, initially, in their general form, as is common in many texts,
but are gradually introduced in discussions where they fit naturally. Even so,
they are treated thoroughly here, unlike in other texts that deal with them only xvii