Engineering Computation with MATLAB, 3rd edition
Published by Pearson (February 24, 2012) © 2013
- David M. Smith Georgia Institute of Technology
This textbook is ideal for MATLAB/Introduction to Programming courses in both Engineering and Computer Science departments.
Engineering Computation with MATLAB introduces the power of computing to engineering students who have no programming experience. The book places the fundamental tenets of computer programming into the context of MATLAB, employing hands-on exercises, examples from the engineering industry, and a variety of core tools to increase programming proficiency and capability. With this knowledge, students are prepared to adapt learned concepts to other programming languages.
- Exercises: Allow students a “Do It Yourself” approach to master concepts by trying what they just learned. Exercises follow each new
topic. - Style Points: Advise students about writing quality code that is easy to understand, debug, and reuse.
- Hints: Enrich students’ understanding of a topic. Hints are interspersed through the book at points where students may benefit from a little extra “aside.”
- Engineering Examples: Provide robust models and apply to real-world issues that will motivate students. Examples from different engineering disciplines are presented at the end of each chapter.
- Special Characters, Reserved Words, and Functions: Provides a quick reference for the key MATLAB principles discussed in each chapter.
- Self Test:Helps students to check their understanding of the material in each chapter.
- Programming Projects: Offer a variety of large-scale projects that students can work on to solidify their skills.
- A freely accessible Companion Website, featuring:
- Solutions to selected Programming Projects
- Selected full-color figures
- Source code for all MATLAB listings
- The following supplements are available to qualified instructors at Addison-Wesley’s Instructor Resource Center. Please visitwww.pearsonhighered.com/irc
- Source Code
- Solutions to all of the Programming Projects
- PowerPoint Lecture Slides
- A new chapter that deals with the fundamentals of graph manipulation from an engineering standpoint–specifically, how to find a minimum spanning tree, and both exact and approximate methods for finding the best path from one point to another.
- Updated examples consistent with MATLAB R2011
- Revised engineering examples integrate concepts throughout the book
- A new emphasis on problem solving skills
Table of Contents
1.1 Background
1.2 History of Computer Architectures
1.2.1 Babbage’s Difference Engine
1.2.2 Colossus
1.2.3 The von Neumann Architecture
1.3 Computing Systems Today
1.3.1 Computer Hardware
1.3.2 Computer Memory
1.3.3 Computer Software
1.3.4 Running a Computer Program
1.4 Running an Interpreted Program
1.5 Problem Solving
2.1 Programming Language Background
2.1.1 Abstraction
2.1.2 Algorithms
2.1.3 Programming Paradigms
2.2 Basic Data Manipulation
2.2.1 Starting and Stopping Matlab
2.2.2 Assigning Values to Variables
2.2.3 Data Typing
2.2.4 Classes and Objects
2.3 the Matlab User Interface
2.3.1 the Interactions Window
2.3.2 the Command History
2.3.3 the Variables Window
2.3.4 the Files Window
2.3.5 Editor Windows
2.3.6 Figure Windows
2.4 Scripts
2.4.1 Text Files
2.4.2 Creating Scripts
2.4.3 The Current Directory
2.4.4 Running Scripts
2.4.5 Punctuating Scripts
2.4.6 Debugging Scripts
2.5 Engineering Example— Spacecraft Launch
3.1 Concept: Using Built-in Functions
3.2 Concept: Data Collections
3.2.1 Data Abstraction
3.2.2 Homogeneous Collection
3.3 Vectors
3.3.1 Creating a Vector
3.3.2 Size of a Vector
3.3.3 Indexing a Vector
3.3.4 Shortening a Vector
3.3.5 Operating on Vectors
3.4 Engineering Example—Forces and Moments
3.5 Arrays
3.5.1 Properties of an Array
3.5.2 Creating an Array
3.5.3 Accessing Elements of an Array
3.5.4 Removing Elements of an Array
3.5.5 Operating on Arrays
3.6 Engineering Example—Computing Soil Volume
4.1 Concept: Code Blocks
4.2 Conditional Execution in General
4.3 if Statements
4.3.1 General Template
4.3.2 Matlab Implementation
4.3.3 Important Ideas
4.4 switch Statements
4.4.1 General Template
4.4.2 Matlab Implementation
4.5 Iteration in General
4.6 for Loops
4.6.1 General for Loop Template
4.6.2 Matlab Implementation
4.6.3 Indexing Implementation
4.6.4 Breaking a for Loop
4.7 while Loops
4.7.1 General while Template
4.7.2 Matlab while Loop Implementation
4.7.3 Loop-and-a-Half Implementation
4.7.4 Breaking a while Loop
4.8 Engineering Example—Computing Liquid Levels
5.1 Concepts: Abstraction and Encapsulation
5.2 Black Box View of a Function
5.3 Matlab Implementation
5.3.1 General Template
5.3.2 Function Definition
5.3.3 Storing and Using Functions
5.3.4 Calling Functions
5.3.5 Returning Multiple Results
5.3.6 Auxiliary Local Functions
5.3.7 Encapsulation in Matlab Functions
5.3.8 Global Variables
5.4 Engineering Example—Measuring a Solid Object
6.1 Character String Concepts: Mapping and Casting
6.2 Matlab Implementation
6.2.1 Slicing and Concatenating Strings
6.2.2 Arithmetic and Logical Operations
6.2.3 Useful Functions
6.3 Format Conversion Functions
6.3.1 Conversion from Numbers to Strings
6.3.2 Conversion from Strings to Numbers
6.4 Character String Operations
6.4.1 Simple Data Output: The disp(...) Function
6.4.2 Complex Output
6.4.3 Comparing Strings
6.5 Arrays of Strings
6.6 Engineering Example— Encryption
7.1 Concept: Collecting Dissimilar Objects
7.2 Cell Arrays
7.2.1 Creating Cell Arrays
7.2.2 Accessing Cell Arrays
7.2.3 Using Cell Arrays
7.2.4 Processing Cell Arrays
7.3 Structures
7.3.1 Constructing and Accessing One Structure
7.3.2 Constructor Functions
7.4 Structure Arrays
7.4.1 Constructing Cell Arrays
7.4.2 Accessing Structure Elements
7.4.3 Manipulating Structures
7.5 Engineering Example—Assembling a Structure
8.1 Concept: Serial Input and Output (I/O)
8.2 Workspace I/O
8.3 High-level I/O Functions
8.3.1 Exploration
8.3.2 Spreadsheets
8.3.3 Delimited Text Files
8.4 Low-level File I/O
8.4.1 Opening and Closing Files
8.4.2 Reading Text Files
8.4.3 Examples of Reading Text Files
8.4.4 Writing Text Files
8.5 Engineering Example— Spreadsheet Data
9.1 Concept:The Activation Stack
9.1.1 A Stack
9.1.2 Activation Stack
9.1.3 Function Instances
9.2 Recursion Defined
9.3 Implementing a Recursive Function
9.4 Exceptions
9.4.1 Historical Approaches
9.4.2 Generic Exception Implementation
9.4.3 Implementation
9.5 Wrapper Functions
9.6 Examples of Recursion
9.6.1 Detecting Palindromes
9.6.2 Fibonacci Series
9.6.3 Zeros of a Function
9.7 Engineering Example—Robot Arm Motion
10.1 Solving Simple Problems
10.2 Assembling Solution Steps
10.3 Summary of Operations
10.3.1 Basic Arithmetic Operations
10.3.2 Inserting into a Collection
10.3.3 Traversing a Collection
10.3.4 Building a Collection
10.3.5 Mapping a Collection
10.3.6 Filtering a Collection
10.3.7 Summarizing a Collection
10.3.8 Searching a Collection
10.3.9 Sorting a Collection
10.4 Solving Larger Problems
10.5 Engineering Example— Processing Geopolitical Data
11.1 Plotting in General
11.1.1 A Figure—The Plot Container
11.1.2 Simple Functions for Enhancing Plots
11.1.3 Multiple Plots on One Figure—Subplots
11.1.4 Manually Editing Plots
11.2 2-D Plotting
11.2.1 Simple Plots
11.2.2 Plot Options
11.2.3 Parametric Plots
11.2.4 Other 2-D Plot Capabilities
11.3 3-D Plotting
11.3.1 Linear 3-D Plots
11.3.2 Linear Parametric 3-D Plots
11.3.3 Other 3-D Plot Capabilities
11.4 Surface Plots
11.4.1 Basic Capabilities
11.4.2 Simple Exercises
11.4.3 3-D Parametric Surfaces
11.4.4 Bodies of Rotation
11.4.5 Other 3-D Surface Plot Capabilities
11.4.6 Assembling Compound Surfaces
11.5 Manipulating Plotted Data
11.6 Engineering Example—Visualizing Geographic Data
11.6.1 Analyzing the Data
11.6.2 Displaying the Data
12.1 Concept: Behavioral Abstraction
12.2 Matrix Operations
12.2.1 Matrix Multiplication
12.2.2 Matrix Division
12.2.3 Matrix Exponentiation
12.3 Implementation
12.3.1 Matrix Multiplication
12.3.2 Matrix Division
12.4 Rotating Coordinates
12.4.1 2-D Rotation
12.4.2 3-D Rotation
12.5 Solving Simultaneous Linear Equations
12.5.1 Intersecting Lines
12.5.2 Curve Fitting
12.6 Engineering Examples
12.6.1 Ceramic Composition
12.6.2 Analyzing an Electrical Circuit
13.1 Nature of an Image
13.2 Image Types
13.2.1 True Color Images
13.2.2 Gray Scale Images
13.2.3 Color Mapped Images
13.2.4 Preferred Image Format
13.3 Reading, Displaying, and Writing Images
13.4 Operating on Images
13.4.1 Stretching or Shrinking Images
13.4.2 Color Masking
13.4.3 Creating a Kaleidoscope
13.4.4 Images on a Surface
13.5 Engineering Example—Detecting Edges
14.1 The Physics of Sound
14.2 Recording and Playback
14.3 Implementation
14.4 Time Domain Operations
14.4.1 Slicing and Concatenating Sound
14.4.2 Musical Background
14.4.3 Changing Sound Frequency
14.5 The Fast Fourier Transform
14.5.1 Background
14.5.2 Implementation
14.5.3 Simple Spectral Analysis
14.6 Frequency Domain Operations
14.7 Engineering Example—Music Synthesizer
15.1 Interpolation
15.1.1 Linear Interpolation
15.1.2 Cubic Spline Interpolation
15.1.3 Extrapolation
15.2 Curve Fitting
15.2.1 Linear Regression
15.2.2 Polynomial Regression
15.2.3 Practical Application
15.3 Numerical Integration
15.3.1 Determination of the Complete Integral
15.3.2 Continuous Integration Problems
15.4 Numerical Differentiation
15.5 Analytical Operations
15.6 Implementation
15.7 Engineering Example—Shaping Synthesizer Notes
16.1 Measuring Algorithm Cost
16.1.1 Specific Big O Examples
16.1.2 Analyzing Complex Algorithms
16.2 Algorithms for Sorting Data
16.2.1 Insertion Sort
16.2.2 Bubble Sort
16.2.3 Quick Sort
16.2.4 Quick Sort in Place
16.2.5 Merge Sort
16.2.6 Radix Sort
16.3 Performance Analysis
16.4 Applications of Sorting Algorithms
16.4.1 Using sort(...)
16.4.2 Insertion Sort
16.4.3 Bubble Sort
16.4.4 Quick Sort
16.4.5 Merge Sort
16.5 Engineering Example—A Selection of Countries
17.1 Queues
17.1.1 The Nature of a Queue
17.1.2 Implementing Queues
17.1.3 Priority Queues
17.1.4 Testing Queues
17.2 Graphs
17.2.1 Graph Examples
17.2.2 Processing Graphs
17.2.3 Building Graphs
17.2.4 Traversing Graphs
17.3 Minimum Spanning Trees
17.4 Finding Paths
17.4.1 Path Search Algorithms
17.4.2 Breadth-First Search (BFS)
17.4.3 Dijkstra’s Algorithm
17.4.4 A* Algorithm
17.4.5 Testing Graph Search Algorithms
17.5 Engineering Applications
Appendix A
Appendix B
Appendix C
Appendix D
1.1 Background
1.2 History of Computer Architectures
1.2.1 Babbage’s Difference Engine
1.2.2 Colossus
1.2.3 The von Neumann Architecture
1.3 Computing Systems Today
1.3.1 Computer Hardware
1.3.2 Computer Memory
1.3.3 Computer Software
1.3.4 Running a Computer Program
1.4 Running an Interpreted Program
1.5 Problem Solving
2.1 Programming Language Background
2.1.1 Abstraction
2.1.2 Algorithms
2.1.3 Programming Paradigms
2.2 Basic Data Manipulation
2.2.1 Starting and Stopping Matlab
2.2.2 Assigning Values to Variables
2.2.3 Data Typing
2.2.4 Classes and Objects
2.3 the Matlab User Interface
2.3.1 the Interactions Window
2.3.2 the Command History
2.3.3 the Variables Window
2.3.4 the Files Window
2.3.5 Editor Windows
2.3.6 Figure Windows
2.4 Scripts
2.4.1 Text Files
2.4.2 Creating Scripts
2.4.3 The Current Directory
2.4.4 Running Scripts
2.4.5 Punctuating Scripts
2.4.6 Debugging Scripts
2.5 Engineering Example— Spacecraft Launch
3.1 Concept: Using Built-in Functions
3.2 Concept: Data Collections
3.2.1 Data Abstraction
3.2.2 Homogeneous Collection
3.3 Vectors
3.3.1 Creating a Vector
3.3.2 Size of a Vector
3.3.3 Indexing a Vector
3.3.4 Shortening a Vector
3.3.5 Operating on Vectors
3.4 Engineering Example—Forces and Moments
3.5 Arrays
3.5.1 Properties of an Array
3.5.2 Creating an Array
3.5.3 Accessing Elements of an Array
3.5.4 Removing Elements of an Array
3.5.5 Operating on Arrays
3.6 Engineering Example—Computing Soil Volume
4.1 Concept: Code Blocks
4.2 Conditional Execution in General
4.3 if Statements
4.3.1 General Template
4.3.2 Matlab Implementation
4.3.3 Important Ideas
4.4 switch Statements
4.4.1 General Template
4.4.2 Matlab Implementation
4.5 Iteration in General
4.6 for Loops
4.6.1 General for Loop Template
4.6.2 Matlab Implementation
4.6.3 Indexing Implementation
4.6.4 Breaking a for Loop
4.7 while Loops
4.7.1 General while Template
4.7.2 Matlab while Loop Implementation
4.7.3 Loop-and-a-Half Implementation
4.7.4 Breaking a while Loop
4.8 Engineering Example—Computing Liquid Levels
5.1 Concepts: Abstraction and Encapsulation
5.2 Black Box View of a Function
5.3 Matlab Implementation
5.3.1 General Template
5.3.2 Function Definition
5.3.3 Storing and Using Functions
5.3.4 Calling Functions
5.3.5 Returning Multiple Results
5.3.6 Auxiliary Local Functions
5.3.7 Encapsulation in Matlab Functions
5.3.8 Global Variables
5.4 Engineering Example—Measuring a Solid Object
6.1 Character String Concepts: Mapping and Casting
6.2 Matlab Implementation
6.2.1 Slicing and Concatenating Strings
6.2.2 Arithmetic and Logical Operations
6.2.3 Useful Functions
6.3 Format Conversion Functions
6.3.1 Conversion from Numbers to Strings
6.3.2 Conversion from Strings to Numbers
6.4 Character String Operations
6.4.1 Simple Data Output: The disp(...) Function
6.4.2 Complex Output
6.4.3 Comparing Strings
6.5 Arrays of Strings
6.6 Engineering Example— Encryption
7.1 Concept: Collecting Dissimilar Objects
7.2 Cell Arrays
7.2.1 Creating Cell Arrays
7.2.2 Accessing Cell Arrays
7.2.3 Using Cell Arrays
7.2.4 Processing Cell Arrays
7.3 Structures
7.3.1 Constructing and Accessing One Structure
7.3.2 Constructor Functions
7.4 Structure Arrays
7.4.1 Constructing Cell Arrays
7.4.2 Accessing Structure Elements
7.4.3 Manipulating Structures
7.5 Engineering Example—Assembling a Structure
8.1 Concept: Serial Input and Output (I/O)
8.2 Workspace I/O
8.3 High-level I/O Functions
8.3.1 Exploration
8.3.2 Spreadsheets
8.3.3 Delimited Text Files
8.4 Low-level File I/O
8.4.1 Opening and Closing Files
8.4.2 Reading Text Files
8.4.3 Examples of Reading Text Files
8.4.4 Writing Text Files
8.5 Engineering Example— Spreadsheet Data
9.1 Concept:The Activation Stack
9.1.1 A Stack
9.1.2 Activation Stack
9.1.3 Function Instances
9.2 Recursion Defined
9.3 Implementing a Recursive Function
9.4 Exceptions
9.4.1 Historical Approaches
9.4.2 Generic Exception Implementation
9.4.3 Implementation
9.5 Wrapper Functions
9.6 Examples of Recursion
9.6.1 Detecting Palindromes
9.6.2 Fibonacci Series
9.6.3 Zeros of a Function
9.7 Engineering Example—Robot Arm Motion
10.1 Solving Simple Problems
10.2 Assembling Solution Steps
10.3 Summary of Operations
10.3.1 Basic Arithmetic Operations
10.3.2 Inserting into a Collection
10.3.3 Traversing a Collection
10.3.4 Building a Collection
10.3.5 Mapping a Collection
10.3.6 Filtering a Collection
10.3.7 Summarizing a Collection
10.3.8 Searching a Collection
10.3.9 Sorting a Collection
10.4 Solving Larger Problems
10.5 Engineering Example— Processing Geopolitical Data
11.1 Plotting in General
11.1.1 A Figure—The Plot Container
11.1.2 Simple Functions for Enhancing Plots
11.1.3 Multiple Plots on One Figure—Subplots
11.1.4 Manually Editing Plots
11.2 2-D Plotting
11.2.1 Simple Plots
11.2.2 Plot Options
11.2.3 Parametric Plots
11.2.4 Other 2-D Plot Capabilities
11.3 3-D Plotting
11.3.1 Linear 3-D Plots
11.3.2 Linear Parametric 3-D Plots
11.3.3 Other 3-D Plot Capabilities
11.4 Surface Plots
11.4.1 Basic Capabilities
11.4.2 Simple Exercises
11.4.3 3-D Parametric Surfaces
11.4.4 Bodies of Rotation
11.4.5 Other 3-D Surface Plot Capabilities
11.4.6 Assembling Compound Surfaces
11.5 Manipulating Plotted Data
11.6 Engineering Example—Visualizing Geographic Data
11.6.1 Analyzing the Data
11.6.2 Displaying the Data
12.1 Concept: Behavioral Abstraction
12.2 Matrix Operations
12.2.1 Matrix Multiplication
12.2.2 Matrix Division
12.2.3 Matrix Exponentiation
12.3 Implementation
12.3.1 Matrix Multiplication
12.3.2 Matrix Division
12.4 Rotating Coordinates
12.4.1 2-D Rotation
12.4.2 3-D Rotation
12.5 Solving Simultaneous Linear Equations
12.5.1 Intersecting Lines
12.5.2 Curve Fitting
12.6 Engineering Examples
12.6.1 Ceramic Composition
12.6.2 Analyzing an Electrical Circuit
13.1 Nature of an Image
13.2 Image Types
13.2.1 True Color Images
13.2.2 Gray Scale Images
13.2.3 Color Mapped Images
13.2.4 Preferred Image Format
13.3 Reading, Displaying, and Writing Images
13.4 Operating on Images
13.4.1 Stretching or Shrinking Images
13.4.2 Color Masking
13.4.3 Creating a Kaleidoscope
13.4.4 Images on a Surface
13.5 Engineering Example—Detecting Edges
14.1 The Physics of Sound
14.2 Recording and Playback
14.3 Implementation
14.4 Time Domain Operations
14.4.1 Slicing and Concatenating Sound
14.4.2 Musical Background
14.4.3 Changing Sound Frequency
14.5 The Fast Fourier Transform
14.5.1 Background
14.5.2 Implementation
14.5.3 Simple Spectral Analysis
14.6 Frequency Domain Operations
14.7 Engineering Example—Music Synthesizer
15.1 Interpolation
15.1.1 Linear Interpolation
15.1.2 Cubic Spline Interpolation
15.1.3 Extrapolation
15.2 Curve Fitting
15.2.1 Linear Regression
15.2.2 Polynomial Regression
15.2.3 Practical Application
15.3 Numerical Integration
15.3.1 Determination of the Complete Integral
15.3.2 Continuous Integration Problems
15.4 Numerical Differentiation
15.5 Analytical Operations
15.6 Implementation
15.7 Engineering Example—Shaping Synthesizer Notes
16.1 Measuring Algorithm Cost
16.1.1 Specific Big O Examples
16.1.2 Analyzing Complex Algorithms
16.2 Algorithms for Sorting Data
16.2.1 Insertion Sort
16.2.2 Bubble Sort
16.2.3 Quick Sort
16.2.4 Quick Sort in Place
16.2.5 Merge Sort
16.2.6 Radix Sort
16.3 Performance Analysis
16.4 Applications of Sorting Algorithms
16.4.1 Using sort(...)
16.4.2 Insertion Sort
16.4.3 Bubble Sort
16.4.4 Quick Sort
16.4.5 Merge Sort
16.5 Engineering Example—A Selection of Countries
17.1 Queues
17.1.1 The Nature of a Queue
17.1.2 Implementing Queues
17.1.3 Priority Queues
17.1.4 Testing Queues
17.2 Graphs
17.2.1 Graph Examples
17.2.2 Processing Graphs
17.2.3 Building Graphs
17.2.4 Traversing Graphs
17.3 Minimum Spanning Trees
17.4 Finding Paths
17.4.1 Path Search Algorithms
17.4.2 Breadth-First Search (BFS)
17.4.3 Dijkstra’s Algorithm
17.4.4 A* Algorithm
17.4.5 Testing Graph Search Algorithms
17.5 Engineering Applications
Appendix A
Appendix B
Appendix C
Appendix D
David Smith has been teaching introductory computer science classes for engineers at the Georgia Institute of Technology since 1997 when he retired from industry. Previously, he worked 31 years for Lockheed-Martin at their Marietta, Georgia, facility as a systems and software specialist with a focus on intelligent systems. He was active in designing and developing software for the C-130J, C-27J, F-22 and C-5 aircraft, and was the technical leader of the Pilot’s Associate program, a $42 million research project sponsored by the Defense Advanced Research Projects Agency.
He has a bachelor’s degree in aeronautical engineering from Southampton University, and a master’s degree in control systems from Imperial College, London.
He has a bachelor’s degree in aeronautical engineering from Southampton University, and a master’s degree in control systems from Imperial College, London.
Need help? Get in touch
Play
Privacy and cookies
By watching, you agree Pearson can share your viewership data for marketing and analytics for one year, revocable by deleting your cookies.