EGR 277 - PowerPoint PPT Presentation

About This Presentation
Title:

EGR 277

Description:

MATLAB Lecture #1 EGR 110 Engineering Graphics Reading Assignment: MATLAB handout MATLAB Assignment: MATLAB Assignment #1 MATLAB MATLAB is an extremely powerful ... – PowerPoint PPT presentation

Number of Views:165
Avg rating:3.0/5.0
Slides: 15
Provided by: tcgo
Learn more at: http://faculty.tcc.edu
Category:
Tags: egr | mathematica

less

Transcript and Presenter's Notes

Title: EGR 277


1
MATLAB Lecture 1 EGR 110 Engineering
Graphics
Reading Assignment MATLAB handout MATLAB
Assignment MATLAB Assignment 1
  • MATLAB
  • MATLAB is an extremely powerful software
    application and development tool that is widely
    used in most universities in technical fields.
    Similar programs include MathCAD and Mathematica.
    In this course some basic features of MATLAB
    will be covered. It is very likely that
    engineering students will see MATLAB used in many
    later undergraduate and graduate engineering
    courses.
  • In the past engineers commonly wrote programs to
    perform various types of engineering
    calculations. Many of those calculations can now
    be easily performed with functions and features
    that are built into MATLAB, including
  • mathematical, statistical, and logical
    functions
  • graphing functions
  • curve-fitting
  • equation solving
  • symbolic calculations
  • advanced functions with applications in later
    engineering courses

So why is it called MATLAB? MATLAB is short for
MATrix LABoratory. MATLAB was originally
designed for manipulating matrices. In fact,
when you use a simple variable such as x in
MATLAB, it is actually stored as a (1x1) matrix.
In order to understand how MATLAB works, we will
need to be familiar with matrix calculations. We
will cover more on this topic later.
2
MATLAB Lecture 1 EGR 110 Engineering
Graphics
MATLAB Environment When MATLAB is launched,
several windows will appear. An important part
of learning MATLAB is learning how to use each of
these windows.
Workspace Window
Current Folder Window
Command Window
Command History Window
  • As we will see later, MATLAB uses a number of
    other windows as well, including
  • Editor for creating and editing MATLAB
    programs
  • Array editor
  • Help window
  • Properties windows

3
MATLAB Lecture 1 EGR 110 Engineering
Graphics
Vectors and scalars in MATLAB MATLAB is designed
to work with vector quantities places in
matrices, where the elements of the matrix are
placed inside brackets with the elements in
each row separated by spaces and the rows
separated by semicolons. However, MATLAB can
also be used to work with variables defined by a
single value called scalars.
  • Variable names in MATLAB
  • are case-sensitive
  • can contain up to 63 characters (any characters
    beyond the 63rd are ignored)
  • must start with a letter, followed by any comb.
    of letters, numbers, and underscores
  • cannot contain spaces
  • Examples (List several in class)

4
MATLAB Lecture 1 EGR 110 Engineering
Graphics
Expressions in MATLAB MATLAB, like most
programming languages, requires that expressions
contain a single variable to the left of the
assignment operator (equals sign). Example
X 2A 3B - 15
Assignment operator
Single variable
Expression involving variables, functions,
numbers, etc
Additionally, MATLAB performs the calculations to
the right of the assignment operator () using
existing values of variables and then assigns the
result to the variable to the left of the equals
sign. So the expression X X 2 should be
interpreted as Xnew Xold 2
Note the result of the following sequence of
instructions in MATLAB (try it!)
Note a semicolon () after a command suppresses
the value from being printed
5
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
MATLABs Basic Scalar Arithmetic Operators
MATLABs Order of Operations (for
scalars) Operators are executed left to right
using the following precedence.
 
Examples (List several in class)
6
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
Examples (Order of operations) Try these by
hand and then verify in MATLAB.
 
7
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
Examples (Order of operations) Write MATLAB
expressions for F1 F5, then test them in MATLAB
using A 5, B 4, C 3, and D 2.
 
8
MATLAB Lecture 1 EGR 110 Engineering
Graphics
MATLAB built-in functions MATLAB has hundreds of
built-in functions. A few of the functions
commonly used with scalars are shown in the table.
More functions Open MATLAB and select Help
Function Browser and check out the vast number of
functions available in MATLAB. What do the
following functions do? sind(A) hypot
(a,b) cot(A) mod(N)
9
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
Examples (Functions) Write MATLAB expressions
for each of the following functions. Check the
results using MATLAB.
 
10
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
Examples (Functions) Write MATLAB expressions
for each of the following functions. Check the
results using MATLAB.
 
11
MATLAB Lecture 1 EGR 110 Engineering
Graphics
 
Examples Verify the following identity in
MATLAB. Do so by evaluating the left side of the
equation and the right side of the equation to
show that they yield the same result. Test the
results for ? 0?, 60? and 100?.
 
12
MATLAB Lecture 1 EGR 110 Engineering
Graphics
MATLAB Format Commands MATLAB offers a few
commands for controlling the format of the
output. Additional useful commands are provided
on the next page.
13
MATLAB Lecture 1 EGR 110 Engineering
Graphics
14
MATLAB Lecture 1 EGR 110 Engineering
Graphics
Write a Comment
User Comments (0)
About PowerShow.com