## Table of Contents

1. Introduction to MATLAB®

1.1 Solving engineering problems with MATLAB®

1.2 MATLAB® background

1.3 MATLAB® and the interpreter

1.4 Computer basics

1.5 Binary numbers

1.6 A brief tour of a computer

2. Variables, Assignments, and Expressions

2.1 Variables and assignments

2.2 Identifiers

2.3 Numeric variables

2.4 Numeric expressions

2.5 Mathematical constants

2.6 Repeated commands and the up-arrow key

2.7 String scalars

2.8 Accuracy and rounding error

2.9 Saving and loading variables

3. Logic

3.1 Logical variables

3.2 Logical operators

3.3 Logical expressions

3.4 Logic short circuit evaluation

3.5 Logic precedence rules

3.6 Comparing floating-point numbers for equality

4. Scripts/Functions

4.1 Scripts

4.2 Comments and clear code

4.3 Custom functions: Basics

4.4 Internal mathematical functions

4.5 Basic input

4.6 Basic output I: disp

4.7 Basic output II: fprintf

4.8 Floating-point formatting in fprintf

5. 1D Array Basics

5.1 Introduction to arrays

5.2 Row arrays

5.3 Constructing row arrays

5.4 Column arrays

6. 1D Array Intermediary

6.1 Row array resizing

6.2 Multi-element row array indexing using integer arrays

6.3 More indexing

6.4 Functions to create numeric row arrays

6.5 1D element-wise arithmetic operators

6.6 Further study: MATLAB® programming environment and 1D arrays

7. 1D Array Advanced

7.1 Logical operators and 1D arrays

7.2 Logical indexing

7.3 Multi-element row array indexing using logical arrays

7.4 Relational operators and row arrays

7.5 Relational operators and 1D arrays

8. 1D Array Apps Intro

8.1 Functions and 1D arrays

8.2 Incremental programming: Green Monster example

8.3 Audio signal processing

9. 1D Array Numeric Apps

9.1 Rounding functions

9.2 Remainder functions

9.3 Summation function

9.4 Complex number functions

9.5 Statistics functions

9.6 Pseudo-random number generators

9.7 Discrete integer mathematics functions

9.8 Rational approximation functions

10. 2D Array Basics

10.1 2D arrays: Introduction

10.2 Indexing an element in a 2D array

10.3 Concatenation

10.4 Multi-element 2D array indexing using integer arrays

10.5 Indexing rows and columns using a single colon

10.6 Manipulating 2D arrays using a single colon

10.7 Multi-element 2D array indexing using logical arrays

10.8 Defining logical indexing arrays using relational expressions

10.9 Indexing 2D arrays using the end keyword

10.10 Additional 2D array material

11. 2D Array Advanced 1

11.1 Dimensional properties of arrays

11.2 Elementary 2D arrays

11.3 Array manipulation

11.4 Replicating and tiling arrays

11.5 Reshaping arrays

12. 2D Array Advanced 2

12.1 Find function

12.2 Sorting

12.3 2D element-wise arithmetic operators

12.4 Logical functions for arrays

12.5 Functions and two-dimensional arrays

13. Data Visualization Basics

13.1 Simple plotting

13.2 2D data plots I

13.3 2D data plots II

13.4 3D line plots

13.5 Rectangular data grids

14. Data Visualization Intermediary

14.1 3D and higher arrays

14.2 True color/RGB image

14.3 Indexed color image

14.4 Grayscale/intensity images

14.5 Common image file operations

15. Data Visualization Advanced

15.1 Triangular data grids

15.2 3D mesh and surface graphs

15.3 Scatter plots

15.4 Animating plots with loops

15.5 Additional plotting material

16. Branches

16.1 If-else statement

16.2 Relational operators

16.3 Multiple branches

16.4 Logical operators

16.5 Switch statement

17. Loops

17.1 While loops

17.2 More while examples

17.3 Counting

17.4 For loops

17.5 Nested loops

17.6 Loops and arrays

17.7 Break and continue

18. Custom Functions

18.1 Scripts with local functions

18.2 Functions with local functions

18.3 Nested functions

18.4 Anonymous functions

18.5 Function handles

18.6 Scope of variables

18.7 Global variables

18.8 Persistent variables

18.9 Recursion

18.10 Counting function arguments

19. Strings and Characters

19.1 Strings

19.2 Character vector

19.3 Strings append and combine

19.4 String conversions

19.5 Character vector conversions

19.6 Text comparisons

19.7 Text qualities

19.8 Find text

19.9 Manipulating text

20. Structures

20.1 Grouping data: Structure

20.2 Defining a structure

20.3 Accessing a structure

20.4 MATLAB® functions for structures

20.5 Structures as function arguments

20.6 Structure with array fields

20.7 Array of structures

20.8 Structure example: Seat reservation system

21. Object Oriented Programming

21.1 Objects: Introduction

21.2 Classes: Introduction

21.3 Class properties

21.4 Class methods

21.5 Class example: Seat reservation system

21.6 Operator overloading

21.7 Mutators, accessors, and private helpers

21.8 Handle classes

21.9 Handle class example: Ball drop

22. MATLAB® Data Structures I

22.1 Databases

22.2 Table fundamentals: Creation

22.3 Table fundamentals: Extraction

22.4 Categorical arrays

23. MATLAB® Data Structures II

23.1 Cell Arrays: Construction

23.2 Cell Arrays: Accessing a cell

23.3 Cell array example

24. Graphical User Interfaces

24.1 Graphical objects

24.2 Message dialog boxes

24.3 Input dialog boxes

24.4 Sequential GUI programming

24.5 Event-driven GUI programming: App Designer

24.6 Event-driven GUI programming: Guide

24.7 Further study

25. Applied Mathematics

25.1 Interpolation

25.2 Curve fitting: Least squares regression

25.3 Numerical integration

25.4 Numerical differentiation

25.5 Nonlinear equations: Zeros

26. Linear Algebra I

26.1 Vectors

26.2 Matrices

26.3 Matrix transpose

26.4 Matrix calculations

26.5 Square matrices

26.6 Elementary square matrices

26.7 Linear systems

26.8 Square matrices: Solving Ax = b

26.9 Triangular matrix linear equation solvers

26.10 Gaussian elimination I

26.11 Gaussian elimination II

26.12 Gauss-Jordan elimination

27. Linear Algebra II

27.1 Matrix rank

27.2 Properties of the row-echelon matrices of A

27.3 Vector spaces I

27.4 Vector spaces II

27.5 Row vector space of A

27.6 Column vector space of A

27.7 Null vector space of A

27.8 Null vector space of transpose A

27.9 Solutions to Ax = b

27.10 Least squares solutions to Ax = b

27.11 Eigenvalues and eigenvectors

28. Appendix: Symbolic Mathematics

28.1 Symbolic variables

28.2 Symbolic expressions

28.3 Formula manipulation and simplification

28.4 Operators

28.5 Plots

28.6 Series

28.7 Limits

28.8 Algebraic equations

28.9 Calculus

28.10 Ordinary differential equations

28.11 Converting between symbolic and numeric objects

28.12 Linear algebra II

28.13 Vector calculus

28.14 Integral transforms

28.15 Mathematical functions

28.16 Special functions

29. Appendix: Time Series

29.1 Time Series Data

## What You’ll Find In This zyBook:

### More action with less text.

- Strong emphasis on array operations
- 700+ participation and challenge activities: Questions, animations, tools
- Fully embedded MATLAB® homework system
- Ideal for self-paced independent learning, as well as for a traditional class
- With test banks

zyBooks is the first partner to offer MATLAB® in the cloud and integrated within a textbook. MATLAB® and the L-shaped membrane logo® are registered trademarks of The MathWorks, Inc.

## The zyBooks Approach

### Less text doesn’t mean less learning.

Provides interactive learning of programming foundations and MATLAB®. The material emphasizes a solid understanding of 1D and 2D arrays, teaching effective use of the array/matrix operations that make MATLAB® such a powerful engineering tool. Numerous applications demonstrate the usefulness of arrays in practice. The material covers key programming constructs (scripts, functions, branches, loops, etc.), cell arrays, GUIs, and much more. Includes numerous accompanying MATLAB® problems with real-time feedback through the integrated homework system.

## Authors

**Andre Knoesen**

*Professor of Electrical and Computer Engineering
University of California, Davis*

**Rajeevan Amirtharajah**

*Professor of Electrical and Computer Engineering
University of California, Davis*