ENGR 1181 | MATLAB 2: Introduction to MATLAB
Classroom Guide

ENGR 1181 |MATLAB 2: Introduction to MATLAB

Classroom Guide

Learning Objectives

  1. Demonstrate proper usage of basic MATLAB features including:
  2. The Command Window
  3. Script files
  4. Other default windows
  5. Arithmetic operations
  6. Assigning variables and names
  7. Built-in functions
  8. Help command
  9. Identify the need to translate mathematical notation into proper MATLAB syntax

Textbook Reading

Chapter 1

Topics

This class contains the following topics:

  1. Introduce the MATLAB interface
  2. Variables: naming rules & calculations
  3. Built-in Functions
  4. Script files and other commands

Outline

Below is an outline of the topics and the order in which they should be covered:

  1. What is MATLAB?
  2. MATLAB is a software for numerical computations, visualization, and programming.
  3. The name MATLAB stands for MATrix LABoratory. The basic data element used in MATLAB in an array (explained later).
  1. Open MATLAB and describe the display
  2. Ribbon – useful operations
  3. Current Directory – list of files
  4. Workspace – defined variable values
  5. Command history – displays what has been typed
  6. Command window – one location to enter commands

  1. Change the Working Directory
  2. Current working directory is where files are saved and run from.
  3. Good idea to change the working directory to the Z: drive when you first start MATLAB

  1. Show students how to open and save a script file (editor window)
  2. Save on your laptop or Z: drive
  3. Save your work as you go!
  4. Rules for naming script files
  5. No spaces
  6. The name cannot start with a numeric value
  7. No special characters allowed expect for underscore
  8. Show comments and sectioning
  1. Useful Programming Commands (Classroom Activity – MAT 02 Intro, Example 4)
  2. clc
  3. clear
  4. disp()
  5. semicolon (;) to suppress output
  1. Discuss order of precedence (Classroom Activity – Example 1)
  1. Rules for naming variablesand calculations with variables (Classroom Activity – Example 2)
  2. Cannot exceed 63 characters
  3. Must begin with a letter
  4. May contain letters, digits, and the underscore character
  5. No spaces allowed
  6. MATLAB is case sensitive
  7. Avoid naming variables with currently defined MATLAB functions (e.g. exp, sin, cos, sqrt, length, etc.)
  8. Mathematical sense vs. programming language
  1. Show MATLAB’s pre-defined math functions and how to use them in calculations (Classroom Activity – Example 3)
  2. Units for trigonometric functions
  3. sin(x) – radians
  4. sind(x) – degrees
  5. pi vs. pi() from Excel
  6. e^2 vs. exp(2)
  1. Explain how to save MATLAB script files and command windows as a PDF (print to PDF). Show how to combine PDF files into a single PDF.
  1. Students will complete Part 1 of the assignment to turn in by the end of class. Once finished, students may start on Part 2 due by the next class. Students will submit Part 1 of the assignment to the Carmen dropbox as a PDF.

1