# Matlab Fundamentals

## Workshop Overview

MATLAB is an integrated technical computing environment from the MathWorks that combines array-based numeric computation, advanced graphics and visualization, and a high-level programming language. Separately licensed toolboxes provide additional domain-specific functionality.

Participants must have a Mathworks account in order to access the links to the online tutorials in this document.

**Matlab Academy:Fundamentals of Matlab**

**<a href=“https://matlabacademy.mathworks.com/R2019b/portal.html?course=mlbe&s_tid=sched_leaf_spot#chapter=1&lesson=1§ion=1"target="_blank">Video: Fundamentals of Matlab**

**<a href=“https://matlabacademy.mathworks.com/artifacts/quick-reference.html?course=mlbe&release=R2019a&language=en"target="_blank">Quick Reference Guide (used for presentation)**

## Getting Started

### Entering Commands

**Exercise: Valid Variable Names and Cleaning Up**

**Exercise: Change Output Display**

### Getting Data into Matlab

**<a href=“https://matlabacademy.mathworks.com/R2019b/portal.html?course=mlbe&s_tid=sched_leaf_spot#chapter=1&lesson=3§ion=2"target="_blank">Video: Import Tool**

**Exercise: Using the Variable Editor**

**Exercise: Saving Modifications**

### Obtaing Help

**<a href=“https://matlabacademy.mathworks.com/R2019b/portal.html?course=mlbe&s_tid=sched_leaf_spot#chapter=1&lesson=4§ion=2"target="_blank">Video: Using MATLAB’s Documentation**

**Exercise: Open and Use Function Documentation**

## Plotting and Common Modifications

### Plotting

**Exercise: Plotting Gasoline Prices**

### Annotating Plots

**Exercise: Axis Labels and Title**

**Exercise: More Plot Annotation Options**

### Axis Control

**Exercise: Modify Axis Properties**

**Exercise: Modify Gasoline Price Plot Axes**

## Working with Live scripts

### Create and Run a Script

**Exercise: Modifying and Running Scripts**

### Code Sections

**Exercise: International Gasoline Prices**

### Comments and Text

**Exercise: International Gasoline Prices**

## Creating and Manipulating Arrays

### Manually Entering Arrays

### Creating Evenly-Spaced Vectors

**Exercise: Use Colon Operator and Linspace**

### Concatenating Arrays

**Exercise: Concatenating Arrays**

**Exercise: Creating and Concatenating Arrays**

### Array Creation Functions

**Exercise: Creating Arrays of Random Numbers**

### Reshaping Arrays

**Exercise: Overall Average Electricity Revenue**

## Accessing Data in Arrays

### Indexing into Vectors

**Exercise: Accessing and Modifying Vector Values**

**Exercise: Index Using Variables and Keywords**

### Accessing Multiple Elements

**Exercise: Modify Multiple Elements**

### Accessing Data in Matrices

**Exercise: Extract a Single Element**

**Exercise: Matrix Indexing with Vectors**

**Exercise: Extract Multiple Elements**

## Mathematical and Statistical Operations with Arrays

### Performing Operations on Arrays

**Exercise: Basic Array Arithmetic & Functionss**

**Video: Element-wise vs. Matrix Operations**

**Exercise: Element-wise Arithmetic**

**Exercise: Operating on Compatibly-Sized Arrays**

### Matrix Multiplication

**Exercise: Extract Multiple Elements**

### Calculating Statistics of Vectors

**Exercise: Average Gasoline Prices**

### Using Statistical Operations on Matrices

**Exercise: Descriptive Statistics**

**Exercise: Statistics for Each Row**

## Visualizing Data in 2D and 3D

### Identifying Available Vector Plot Types

**Exercise: stairs, stem, and area**

**Exercise: Gasoline Prices Scatter Plot**

### Creating Arrays of Text

**Exercise: Creating Character Arrays**

**Exercise: Creating Multiline Annotations**

### Customizing Plot Properties

**Exercise: Customizing Plot Properties**

### Plotting Multiple Columns

**Exercise: Plotting Matrix Columns**

**Exercise: Plotting Matrix Columns Against a Vector**

### Visualizing Matrices

**Exercise: Surface, Mesh, and Contour**

**Exercise: Visualize Electricity Data**

## Conditional Data Selection

### Logical Operations and Variables

**Exercise: Logical Operations with Arrays**

**Exercise: Finding Winning Team Records**

### Counting Elements

**Exercise: Count true Values in a Logical Vector**

**Exercise: Identify Locations of true Values**

### Logical Indexing

**Exercise: Selecting Teams with Winning Home Record**

## Tables of Data

### Storing Data in a Table

**Exercise: Create a Table from Workspace Variables**

### Sorting Table Data

### Extracting Portions of a Table

**Exercise: Variable Name Indexing**

### Extracting Data from a Table

**Exercise: Indexing with Dot Notation**

**Exercise: Indexing with Curly Braces**

### Exporting Tables

## Organizing Data

### Combining Tables

**Exercise: Concatenating Tables**

### Table Properties

**Exercise: Accessing Table Properties**

### Indexing into Cell Arrays

**Exercise: Indexing Into Cell Arrays**

**Exercise: Extract Multiple Elements**

### Working with Dates and Times

**Video: Data Types for Dates and Times**

**Exercise: Applying Functions to Datetimes**

### Operating on Dates and Times

**Exercise: Operating on Dates and Times**

**Exercise: Working with Durations**

### Representing Discrete Categories

**Exercise: Converting to and Operating on Categoricals**

**Exercise: Category Names and Ordinals**

## Preprocessing Data

### Normalizing Data

**Exercise: Calculate Average Daily Electricity Usage**

### Working with Missing Data

**Exercise: Ignoring NaNs in calculations**

**Exercise: Locating Missing Data**

**Exercise: Removing Rows with Missing Data**

### Interpolating Missing Data

**Exercise: Filling Missing Values**

**Exercise: Interpolating Irregularly-Spaced Data**

## Common Data Analysis Techniques

### Moving Window Operations

**Exercise: Smoothing Electricity Data**

### Linear Correlation

**Exercise: Plotting Electricity Usage**

**Exercise: Correlations in Electricity Usage**

### Polynomial Fitting

**Exercise: Fit a Polynomial to Electricity Usage**

## Programming Constructs

### User Interaction

### Decision Branching

**Exercise: Using if-elseif-else**

### Determining Size

**Exercise: Using size and numel**

### For Loops

**Exercise: Looping Through a Vector**

**Exercise: Finding the Fibonacci Sequence**

### While Loops

## Increasing Automation with Functions

### Creating and Calling Functions

**Exercise: Create and Call a Function**

**Exercise: Electricity Usage Analysis Function**

### Function Files

**Exercise: Compare Using a Tolerance**

### Function Workspaces

### MATLAB Path and Calling Precedence

**Exercise: MATLAB Calling Precedence**

## Troubleshooting Code

### Code Analyzer

**Exercise: Remove Code Analyzer Warnings**

### Debugging Run-Time Errors

**Quiz: Matrix Indexing with Vectors**