Example: tourism industry

Matlab: a Practical Introduction to

matlab : a Practical Introduction to Programming and Problem SolvingMatlab: a Practical Introduction to Programming and Problem SolvingByStormy AttawayCollege of Engineering, Boston UniversityBoston, MAAMSTERDAM BOSTON HEIDELBERG LONDONNEW YORK OXFORD PARIS SAN DIEGOSAN FRANCISCO SINGAPORE SYDNEY TOKYOB utterworth-Heinemann is an imprint of ElsevierThis page intentionally left blankButterworth-Heinemann is an imprint of Elsevier30 Corporate Drive, Suite 400, Burlington, MA 01803, USAL inacre House, Jordan Hill, Oxford OX2 8DP, UKCopyright 2009, Elsevier, Inc.

Matlab: a Practical Introduction to Programming and Problem Solving By Stormy Attaway College of Engineering, Boston University Boston, MA AMSTERDAM • BOSTON • HEIDELBERG • LONDON

Tags:

  Introduction, Practical, Matlab, A practical introduction to

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Matlab: a Practical Introduction to

1 matlab : a Practical Introduction to Programming and Problem SolvingMatlab: a Practical Introduction to Programming and Problem SolvingByStormy AttawayCollege of Engineering, Boston UniversityBoston, MAAMSTERDAM BOSTON HEIDELBERG LONDONNEW YORK OXFORD PARIS SAN DIEGOSAN FRANCISCO SINGAPORE SYDNEY TOKYOB utterworth-Heinemann is an imprint of ElsevierThis page intentionally left blankButterworth-Heinemann is an imprint of Elsevier30 Corporate Drive, Suite 400, Burlington, MA 01803, USAL inacre House, Jordan Hill, Oxford OX2 8DP, UKCopyright 2009, Elsevier, Inc.

2 All rights part of this publication may be reproduced or transmitted in any form or by anymeans, electronic or mechanical, including photocopy, recording, or any informationstorage and retrieval system, without permission in writing from the may be sought directly from Elsevier s Science & Technology RightsDepartment in Oxford, UK: phone: (+44) 1865 843830, fax: (+44) 1865 853333,E-mail: You may also complete your request onlinevia the Elsevier homepage ( ), by selecting Support & Contact then Copyright and Permission and then Obtaining Permissions.

3 Library of Congress Cataloging-in-Publication DataApplication submittedBritish Library Cataloguing-in-Publication DataA catalogue record for this book is available from the British : 978-0-75-068762-1 For information on all Butterworth-Heinemann publicationsvisit our Web site at in Canada08 09 10 9 8 7 6 5 4 3 2 1 Attribution matlab and Handle Graphics are registered trademarks of The MathWorks, 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 AttawayThis page intentionally left blankviiPreface.

4 XiiiPart I Programming and Problem Solving Using matlab ..1 ChAPTer 1 Introduction to matlab ..3 Getting into matlab ..4 Variables and assignment Statements ..6 Initializing, Incrementing, and Decrementing ..8 Variable Names ..8 expressions ..10 The Format function and ellipsis ..10 Operators ..11 Built-In functions and Help ..12 constants ..14 Types ..14 random Numbers ..16 characters and encoding ..18 Vectors and Matrices ..20 creating row Vectors ..21 creating column Vectors ..24 creating Matrix Variables.

5 24 Dimensions ..28 Using functions with Vectors and Matrices ..33 empty Vectors ..33 ChAPTer 2 Introduction to matlab Programming ..41 algorithms ..42 matlab Scripts ..43 Documentation ..45 Input and Output ..46 ContentsContentsviii Input function ..46 Output Statements: disp and fprintf ..48 Scripts with Input and Output ..53 Scripts to Produce and customize Simple Plots ..54 The Plot function ..54 Simple related Plot functions ..57 Introduction to file Input/Output (Load and Save) ..59 Writing Data to a file.

6 60 appending Data to a Data file ..61 reading from a file ..61 User-Defined functions that return a Single function Definitions ..65 calling a function ..66 calling a User-Defined function from a Script ..67 Passing Multiple arguments ..67 functions with Local 3 Selection Statements ..79 relational expressions ..80 The if representing Logical True and The if-else Statement ..87 Nested if-else Statements ..88 The Switch Statement ..93 The Menu function ..96 The is functions in matlab .

7 98 ChAPTer 4 Looping ..109 The for Loop ..110 finding Sums and Products ..111 combining for Loops with if Statements ..118 for Loops that Do Not Use the Iterator Variable in the action ..119 Input in a for Loop ..120 Nested for Loops ..122 Nested Loops and Matrices ..126 combining Nested for Loops and if Statements ..130 Vectorizing ..131 Logical Vectors ..133 Vectors and Matrices as function arguments ..140ixContents While Multiple conditions in a While Loop ..145 reading from a file in a While Loop.

8 145 Input in a While Loop ..147 counting in a While Loop ..148 error-checking User Input in a While Loop ..149 ChAPTer 5 matlab Programs ..161 More Types of User-Defined functions ..162 functions that return More than One Value ..162 functions that accomplish a Task Without returning Values ..166 functions that return Values Versus Printing ..167 Passing arguments to functions ..168 matlab Program Organization ..170 Modular Programs ..170 Subfunctions ..172 application: Menu-Driven Modular Program.

9 174 Variable Scope ..182 Persistent Variables ..184 Debugging Techniques ..185 Types of errors ..186 Tracing ..188 function Stubs ..190 ChAPTer 6 String Manipulation ..197 creating String Variables ..198 Strings as Vectors ..198 Operations on Strings ..200 concatenation ..200 creating customized Strings ..202 removing Whitespace characters ..206 changing case ..207 comparing Strings ..207 finding, replacing, and Separating Strings ..209 evaluating a String ..213 The is function for Strings.

10 214 converting between String and Number Types ..215 ContentsxChAPTer 7 Data Structures: cell arrays and Structures ..223 cell arrays ..224 creating cell arrays ..224 Structures ..229 creating and Modifying Structure Variables ..229 Passing Structures to functions ..231 related Structure functions ..232 Vectors of Nested Structures ..241 Vectors of Nested Structures ..243 ChAPTer 8 advanced file Input and Output ..253 Lower Level file I/O functions ..254 Opening and closing a file ..254 reading from files.


Related search queries