Matlab: a Practical Introduction to

[Pages:473] Matlab: A Practical Introduction to Programming and Problem Solving

Matlab: A Practical Introduction to Programming and Problem Solving

By

Stormy Attaway

College of Engineering, Boston University Boston, MA

AMSTERDAM ? BOSTON ? HEIDELBERG ? LONDON NEW YORK ? OXFORD ? PARIS ? SAN DIEGO

SAN FRANCISCO ? SINGAPORE ? SYDNEY ? TOKYO

Butterworth-Heinemann is an imprint of Elsevier

This page intentionally left blank

Butterworth-Heinemann is an imprint of Elsevier 30 Corporate Drive, Suite 400, Burlington, MA 01803, USA Linacre House, Jordan Hill, Oxford OX2 8DP, UK Copyright ? 2009, Elsevier, Inc. All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission in writing from 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: permissions@. You may also complete your request online via the Elsevier homepage (), by selecting "Support & Contact" then "Copyright and Permission" and then "Obtaining Permissions." Library of Congress Cataloging-in-Publication Data Application submitted British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library. ISBN: 978-0-75-068762-1 For information on all Butterworth-Heinemann publications visit our Web site at

Attribution MATLAB? and Handle Graphics? are registered trademarks of The MathWorks, Inc.

Printed in Canada 08? 09? 10?? 9? 8? 7? 6? 5? 4? 3? 2? 1

Dedication

This book is dedicated to my two mentors at Boston University: the late Bill Henneman of the Computer Science Department, and the late Merrill Ebner

of the Department of Manufacturing Engineering. Stormy Attaway

This page intentionally left blank

Contents

Preface.................................................................................................. xiii

Part I

Programming and Problem Solving Using MATLAB............................................................. 1

Chapter 1

Introduction to MATLAB................................................... 3 1.1 Getting into MATLAB............................................................ 4 1.2 Variables and Assignment Statements................................. 6

1.2.1 Initializing, Incrementing, and Decrementing............ 8 1.2.2 Variable Names.............................................................. 8 1.3 Expressions........................................................................... 10 1.3.1 The Format Function and Ellipsis............................. 10 1.3.2 Operators...................................................................... 11 1.3.3 Built-In Functions and Help........................................ 12 1.3.4 Constants..................................................................... 14 1.3.5 Types............................................................................ 14 1.3.6 Random Numbers........................................................ 16 1.4 Characters and Encoding..................................................... 18 1.5 Vectors and Matrices............................................................ 20 1.5.1 Creating Row Vectors................................................. 21 1.5.2 Creating Column Vectors............................................ 24 1.5.3 Creating Matrix Variables........................................... 24 1.5.4 Dimensions................................................................... 28 1.5.5 Using Functions with Vectors and Matrices............. 33 1.5.6 Empty Vectors.............................................................. 33

Chapter 2

Introduction to MATLAB Programming......................... 41

2.1 Algorithms............................................................................. 42 2.2 MATLAB Scripts................................................................... 43

2.2.1 Documentation............................................................. 45 2.3 Input and Output.................................................................. 46

vii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download