Table Of ContentEngineering Computations and Modeling in
MATLAB®/Simulink®
FFMM..iinndddd ii 2266//0055//1111 1111::4499 AAMM
FFMM..iinndddd iiii 2266//0055//1111 1111::4499 AAMM
Engineering Computations
and Modeling
in MATLAB®/Simulink®
Oleg A. Yakimenko
Naval Postgraduate School
Monterey, California
EDUCATION SERIES
Joseph A. Schetz
Editor-in-Chief
Virginia Polytechnic Institute and State University
Blacksburg, Virginia
Published by the
american institute of aeronautics and astronautics, inc.
1801 alexander bell drive, reston, virginia 20191-4344
FFMM..iinndddd iiiiii 2266//0055//1111 1111::4499 AAMM
American Institute of Aeronautics and Astronautics, Inc., Reston, Virginia
1 2 3 4 5
Library of Congress Cataloging-in-Publication Data
Yakimenko, Oleg A.
Engineering computations and modeling in MATLAB/Simulink / Oleg A.
Yakimenko.
p. cm. (AIAA education Series)
ISBN 978-1-60086-781-1
1. Engineering mathematics—Data processing. 2. Computer
programming. 3. MATLAB. 4. SIMULINK. I. Title.
TA345.Y35 2011
620.00285—dc22
2010052540
MATLAB® and Simulink® are registered trademarks of the MathWorks, Inc., 3 Apple
Hill Drive, Natick, MA 01760-2098, USA, www.mathworks.com.
Copyright © 2011 by the American Institute of Aeronautics and Astronautics, Inc. All
rights reserved. Printed in the United States of America. No part of this publication
may be reproduced, distributed, or transmitted, in any form or by any means, or
stored in a database or retrieval system, without the prior written permission of the
publisher.
Data and information appearing in this book are for informational purposes only.
AIAA is not responsible for any injury or damage resulting from use or reliance, nor
does AIAA warrant that use or reliance will be free from privately owned rights.
FFMM..iinndddd iivv 2266//0055//1111 1111::4499 AAMM
AIAA EDUCATION SERIES
Editor-In-Chief
Joseph A. Schetz
Virginia Polytechnic Institute and State University
Editorial Board
Takahira Aoki Brian Landrum
University of Tokyo University of Alabama in Huntsville
João Luiz F. Azevedo Timothy C. Lieuwen
Comando-Geral De Tecnologia Georgia Institute of Technology
Aeroespacial
Michael Mohaghegh
Karen D. Barker The Boeing Company
Robert H. Bishop Conrad F. Newberry
University of Texas at Austin
Brett Newman
Richard Colgren Old Dominion University
University of Kansas
Joseph N. Pelton
James R. DeBonis George Washington University
NASA Glenn Research Center
Mark A. Price
Kajal K. Gupta Queen’s University Belfast
NASA Dryden Flight Research Center
David M. Van Wie
Rikard B. Heslehurst Johns Hopkins University
University of New South Wales
Rakesh K. Kapania
Virginia Polytechnic Institute and
State University
FFMM..iinndddd vv 2266//0055//1111 1111::4499 AAMM
To Ella and Anatoliy
FFMM..iinndddd vvii 2266//0055//1111 1111::4499 AAMM
TABLE OF CONTENTS
List of Color Plates xiii
Preface xv
Conventions xxi
List of Acronyms xxiii
Part 1 Basics of MATLAB
Chapter 1 MATLAB/Simulink as a Technical Computing
Language 1
1.1 Introduction 1
1.2 History of MATLAB Creation and Development 2
1.3 Capabilities and Resources 4
1.4 Aerospace Application Tools 7
1.5 Overview of MathWorks Products 8
Chapter 2 Development Environment and Basic Operations 19
2.1 Introduction 19
2.2 MATLAB Development Environment 19
2.3 Help System 40
2.4 Basic Functions and Utilities 43
2.5 Order of Precedence 52
2.6 Managing Work Session 53
2.7 Changing Preferences 59
2.8 Problem-Solving Methodology 62
Problems 64
Chapter 3 Arrays and Array Operations 67
3.1 Introduction 67
3.2 Types of Arrays and Indexing Their Elements 68
3.3 Array Operations 86
3.4 Array Functions 95
3.5 Using MATLAB Matrix Formalism to Handle
Polynomials 102
vii
FFMM..iinndddd vviiii 2266//0055//1111 1111::4499 AAMM
viii Engineering Computations and Modeling in MATLAB®/Simulink®
3.6 Handling Text Strings as Character Arrays 107
Problems 114
Chapter 4 Data Structures, Types of Files, Managing Data Input
and Output 117
4.1 Introduction 117
4.2 Data Types 118
4.3 Cell Arrays 120
4.4 Structure Arrays 124
4.5 Types of MATLAB Files 129
4.6 Recording MATLAB Sessions and Storing Workspace
Variables 130
4.7 Importing and Exporting Data 132
4.8 Writing and Displaying Formatted Data 142
4.9 Interactive Input and Output 145
Problems 152
Chapter 5 Programming in MATLAB 155
5.1 Introduction 155
5.2 Relational Operators 156
5.3 Logical (Boolean) Operators and Functions 157
5.4 Conditional Statements 160
5.5 Loops 163
5.6 switch Structure 167
5.7 Script Files 168
5.8 Functions 170
5.9 Developing Professional Looking Functions 185
5.10 Editing and Debugging 193
Problems 216
Chapter 6 2-D and 3-D Plotting and Animation 219
6.1 Introduction 219
6.2 Anatomy of 2-D (x−y) Plots in MATLAB 220
6.3 Line Specifications 225
6.4 Accessing Plot Properties via the get and set Functions 228
6.5 Text Strings 234
6.6 Overlays, Legends, Subplots, and Multiple Figures 237
6.7 Special Types of 2-D Plots 245
6.8 3-D Plots 250
6.9 Changing Color Palette 264
6.10 Easy-to-Use Function Plots 267
6.11 Plot Editing 268
FFMM..iinndddd vviiiiii 2266//0055//1111 1111::4499 AAMM
CONTENTS ix
6.12 Interactive Plotting and Animation 273
6.13 Requirements to Engineering Plots 283
Problems 283
Part 2 Symbolic Math Toolbox
Chapter 7 Symbolic Math Toolbox 285
7.1 Introduction 285
7.2 Symbolic Math Toolbox Overview 286
7.3 Getting Started 288
7.4 Basic Operations 293
7.5 Linear Algebra and Calculus 295
7.6 Solving Algebraic and Differential Equations 300
7.7 Simplification and Substitution 303
7.8 Other Functions 308
7.9 MuPAD Development Environment 313
7.10 Plotting Symbolic Expressions 323
7.11 Using Symbolic Expressions in Numerical Operations 327
7.12 LaTeX Representation of Symbolic Expression 332
7.13 Symbolic Calculators 333
Problems 336
Part 3 Numerical Methods in MATLAB
Chapter 8 Accuracy of Digital Computations 337
8.1 Introduction 337
8.2 Accuracy and Precision of Calculations and
Measurements 338
8.3 Computer Number Representation 339
8.4 Round-off Errors 354
8.5 Truncation Errors 358
8.6 Control of Numerical Errors 367
Problems 369
Chapter 9 Numerical Linear Algebra and Eigenvalue Problems 371
9.1 Introduction 371
9.2 Classification of LAEs 372
9.3 Inhomogeneous Sets of LAEs 373
9.4 Matrix Decompositions 388
9.5 Special Cases of LAEs 391
9.6 Applying Linear Algebra to Solve Systems of ODEs 403
FFMM..iinndddd iixx 2266//0055//1111 1111::4499 AAMM