MATLAB RECIPES a problem-solution approach. [2 ed.] 9781484261248, 1484261240

739 142 10MB

English Pages [423] Year 2021

Report DMCA / Copyright

DOWNLOAD FILE

MATLAB RECIPES a problem-solution approach. [2 ed.]
 9781484261248, 1484261240

Table of contents :
Contents
About the Authors
Acknowledgements
Introduction
I Coding in MATLAB
1 Coding Handbook
MATLAB Language Primer
Brief Introduction to MATLAB
Everything Is a Matrix
Strings Are Simple
Use Strict Data Structures
Cell Arrays Hold Anything and Everything
Optimize Your Code with Logical Arrays
Use Persistent and Global Scope to Minimize Data Passing
Understanding Unique MATLAB Operators and Keywords
Colon
Tilde
Dot
end
Harnessing the Power of Multiple Inputs and Outputs
Use Function Handles for Efficiency
Numerics
Images
Datastore
Tall Arrays
Sparse Matrices
Tables and Categoricals
Large MAT-files
Advanced Data Types
1.1 Initializing a Data Structure Using Parameters
Problem
Solution
How It Works
1.2 Performing mapreduce on an Image Datastore
Problem
Solution
How It Works
1.3 Creating a Table from a File
Problem
Solution
How It Works
1.4 Processing Table Data
Problem
Solution
How It Works
1.5 String Concatenation
Problem
Solution
How It Works
1.6 Arrays of Strings
Problem
Solution
How It Works
1.7 Non-English Strings
Problem
Solution
How It Works
1.8 Substrings
Problem
Solution
How It Works
1.9 Using JSON-Formatted Strings
1.10 Creating Function Help
Problem
Solution
How It Works
1.11 Locating Directories for Data Storage
Problem
Solution
How It Works
1.12 Loading Binary Data from a File
Problem
Solution
How It Works
1.13 Command-Line File Interaction
Problem
Solution
How It Works
1.14 Using a MEX File to Link to an External Library
Problem
Solution
How It Works
1.15 Protect Your IP with Parsed Files
Problem
Solution
How It Works
1.16 Writing to a Text File
Problem
Solution
How It Works
1.17 Using an Explicit Expansion
Problem
Solution
How It Works
1.18 Using a Script Subfunction
Problem
Solution
How It Works
1.19 Using Memoize
Problem
Solution
How It Works
1.20 Using Java
Problem
Solution
How It Works
1.21 Creating Documents
Problem
Solution
How It Works
1.22 MATLAB Online
Problem
Solution
How It Works
2 MATLAB Style
2.1 Developing Your Own MATLAB Style Guidelines
Problem
Solution
How It Works
2.2 Writing Good Function Help
Problem
Solution
How It Works
2.3 Overloading Functions and Utilizing varargin
Problem
Solution
How It Works
2.4 Adding Built-in Inputs and Outputs to Functions
Problem
Solution
How It Works
2.5 Adding Argument Checking to Functions
Problem
Solution
How It Works
2.6 Adding Dot Indexing
Problem
Solution
How It Works
2.7 Smart Structuring of Scripts
Problem
Solution
How It Works
2.8 Implementing MATLAB Command-Line Help for Folders
Problem
Solution
How It Works
2.9 Publishing Code into Technical Reports
Problem
Solution
How It Works
2.10 Integrating Toolbox Documentation into the MATLAB Help System
Problem
Solution
How It Works
2.11 Structuring a Toolbox
Problem
Solution
How It Works
3 Visualization
3.1 Plotting Data Interactively from the MATLAB Desktop
Problem
Solution
How It Works
3.2 Incrementally Annotate a Plot
Problem
Solution
How It Works
3.3 Create a Custom Plot Page with Subplot
Problem
Solution
How It Works
3.4 Create a Heat Map
Problem
Solution
How It Works
3.5 Create a Plot Page with Custom-Sized Axes
Problem
Solution
How It Works
3.6 Plotting with Dates
Problem
Solution
How It Works
3.7 Generating a Color Distribution
Problem
Solution
How It Works
3.8 Visualizing Data over 2D or 3D Grids
Problem
Solution
How It Works
3.9 Generate 3D Objects Using Patch
Problem
Solution
How It Works
3.10 Working with Light Objects
Problem
Solution
How It Works
3.11 Programmatically Setting the Camera Properties
Problem
Solution
How It Works
3.12 Display an Image
Problem
Solution
How It Works
3.13 Graph and Digraph
Problem
Solution
How It Works
3.14 Adding a Watermark
Problem
Solution
How It Works
4 Interactive Graphics
4.1 Creating a Simple Animation
Problem
Solution
How It Works
4.2 Playing Back an Animation
Problem
Solution
How It Works
4.3 Animate Line Objects
Problem
Solution
How It Works
4.4 Implementation of a uicontrol Button
Problem
Solution
How It Works
4.5 Display Status of a Running Simulation or Loop
Problem
Solution
How It Works
4.6 Create a Custom GUI with App Designer
Problem
Solution
How It Works
4.7 Build a Data Acquisition GUI
Problem
Solution
How It Works
5 Testing and Debugging
5.1 Creating a Unit Test
Problem
Solution
How It Works
5.2 Running a Test Suite
Problem
Solution
How It Works
5.3 Setting Verbosity Levels in Tests
Problem
Solution
How It Works
5.4 Create a Logging Function to Display Data
Problem
Solution
How It Works
5.5 Generating and Tracing MATLAB Errors and Warnings
Problem
Solution
How It Works
5.6 Testing Custom Errors and Warnings
Problem
Solution
How It Works
5.7 Testing Generation of Figures
Problem
Solution
How It Works
6 Classes
6.1 Object-Oriented Programming
6.2 State Space Systems Base Class
Problem
Solution
How It Works
6.3 State Space Systems Discrete Class
Problem
Solution
How It Works
6.4 Using the State Space Class
Problem
Solution
How It Works
6.5 Using a Mocking Framework
Problem
Solution
How It Works
II Applications
7 The Double Integrator
7.1 Writing the Equations for the Double Integrator Model
Problem
Solution
How It Works
7.2 Creating a Fixed-Step Numerical Integrator
Problem
Solution
How It Works
Mathematical Modeling
MATLAB Code
7.3 Implement a Discrete Proportional-DerivativeController
Problem
Solution
How It Works
7.4 Double Integrator Simulation
Problem
Solution
How It Works
7.5 Create Time Axes with Reasonable Time Units
Problem
Solution
How It Works
7.6 Create Figures with Multiple Subplots
Problem
Solution
How It Works
8 Robotics
8.1 Creating a Dynamical Model of the SCARA Robot
Problem
Solution
How It Works
8.2 Customize a Visualization Function for the Robot
Problem
Solution
How It Works
8.3 Using Numerical Search for Robot Inverse Kinematics
Problem
Solution
How It Works
8.4 Developing a Control System for the Robot
Problem
Solution
How It Works
8.5 Simulating the Controlled Robot
Problem
Solution
How It Works
Summary
9 Electric Motors
9.1 Motor Model
Problem
Solution
How It Works
9.2 Controlling the Motor
Problem
Solution
How It Works
9.3 Pulsewidth Modulation of the Switches
Problem
Solution
How It Works
9.4 Simulating the Controlled Motor
Problem
Solution
How It Works
10 Fault Detection
10.1 Modeling an Air Turbine
Problem
Solution
How It Works
10.2 Building a Detection Filter
Problem
Solution
How It Works
10.3 Simulating the Fault Detection System
Problem
Solution
How It Works
10.4 Building a GUI for the Detection Filter Simulation
Problem
Solution
How It Works
11 Chemical Processes
11.1 Modeling the Chemical Mixing Process
Problem
Solution
How It Works
11.2 Sensing the pH of the Chemical Process
Problem
Solution
How It Works
11.3 Controlling the Effluent pH
Problem
Solution
How It Works
11.4 Simulating the Controlled pH Process
Problem
Solution
How It Works
12 Aircraft
12.1 Creating a Dynamical Model of an Aircraft
Problem
Solution
How It Works
12.2 Equilibrium Control
Problem
Solution
How It Works
12.3 Designing a Control System for an Aircraft
Problem
Solution
How It Works
12.4 Plotting a 3D Trajectory for an Aircraft
Problem
Solution
How It Works
12.5 Simulating the Controlled Aircraft
Problem
Solution
How It Works
12.6 Draw an Aircraft
Problem
Solution
How It Works
13 Spacecraft Attitude Control
13.1 Creating a Dynamical Model of the Spacecraft
Problem
Solution
How It Works
13.2 Computing Angle Errors from Quaternions
Problem
Solution
How It Works
13.3 Simulating the Controlled Spacecraft
Problem
Solution
How It Works
13.4 Performing Batch Runs of a Simulation
Problem
Solution
How It Works
14 Automobiles
14.1 Automobile Dynamics
Problem
Solution
How It Works
14.2 Modeling the Automobile Radar
Problem
Solution
How It Works
14.3 Automobile Autonomous Passing Control
Problem
Solution
How It Works
14.4 Automobile Animation
Problem
Solution
How It Works
14.5 Modeling an Automobile Suspension
Problem
Solution
How It Works
Bibliography
Index

Polecaj historie