Introduction to Matlab - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Introduction to Matlab

Description:

Introduction to Matlab – PowerPoint PPT presentation

Number of Views:65
Avg rating:3.0/5.0
Slides: 13
Provided by: jaredhj
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Matlab


1
Introduction to Matlab
  • Matlab and toolboxes
  • Matrices
  • Built-in functions
  • Plotting
  • Matlab exercise

2
Matlab and Toolboxes
  • Matlab
  • A high-level language and interactive environment
    that enables you to perform computationally
    intensive tasks faster than with traditional
    programming languages such as C, C, and
    Fortran.
  • Matlab toolboxes
  • Optimization toolbox extends the Matlab
    technical computing environment with tools and
    widely used algorithms for standard and
    large-scale optimization.
  • Statistics toolbox provides engineers,
    scientists, researchers, financial analysts, and
    statisticians with a comprehensive set of tools
    to assess and understand their data.
  • From http//www.mathworks.com/

3
Matlab Workspace and Toolbar
  • Variables are stored in the workspace
  • who list current variables
  • whos detailed list of variables
  • clear removes all variables from the workspace
  • Matlab files must be in either the working
    directory or in a directory listed in the search
    path
  • pwd displays the current working directory
  • what lists Matlab specific files in the working
    directory
  • cd change current working directory
  • path displays the current search path

Workspace Browser Path Browser Simulink Help
Window
4
Help
  • Within Matlab
  • Type help at the Matlab prompt or help followed
    by a function name for help on a specific
    function
  • Online
  • Online documentation for Matlab at the MathWorks
    website
  • http//www.mathworks.com/access/helpdesk/help/tech
    doc/matlab.html
  • There are also numerous tutorials online that are
    easily found with a web search.

5
Matrices
  • Entering a matrix
  • A -1 1 23,-1,1 -1, 3, 4
  • A
  • -1 1 2
  • 3 -1 1
  • -1 3 4
  • Matrix operations
  • AA
  • A-A
  • 3A
  • AA
  • ans
  • 2 4 7
  • -7 7 9
  • Matrix referencing
  • A(1,3)
  • ans
  • 2
  • A(2,)
  • ans
  • 3 -1 1
  • A.A
  • ans
  • 1 1 4
  • 9 1 1
  • 1 9 16

6
Built-in Functions
  • Inverse
  • inv(A)
  • ans
  • -0.7000 0.2000 0.3000
  • -1.3000 -0.2000 0.7000
  • 0.8000 0.2000 -0.2000
  • Transpose
  • A'
  • ans
  • -1 3 -1
  • 1 -1 3
  • 2 1 4
  • Determinant
  • det(A)
  • ans
  • 10
  • Rank
  • rank(A)
  • ans
  • 3

7
Linear Algebraic Systems
  • Linear system of algebraic equations
  • b 2 6 4
  • rank(A)
  • ans
  • 3
  • x inv(A)b
  • x
  • 1.0000
  • -1.0000
  • 2.0000

8
Eigenvalues
  • eig(A)
  • ans
  • -1.3777 0.4526i
  • -1.3777 - 0.4526i
  • 4.7554
  • p poly(A)
  • p
  • 1.0000 -2.0000 -11.0000 -10.0000
  • roots(p)
  • ans
  • 4.7554
  • -1.3777 0.4526i
  • -1.3777 - 0.4526i

9
Eigenvalues cont.
  • trace(A)
  • ans
  • 2
  • det(A)
  • ans
  • 10
  • sum(eig(A))
  • ans
  • 2.0000
  • prod(eig(A))
  • ans
  • 10.0000

10
Plotting Commands
  • Basic plots and graphs
  • plot(X,Y) plot vectors or matrices
  • hold hold current graph (for multiple plots on
    same graph)
  • subplot(m,n,p) create axes in tiled positions
    (for multiple graphs in same figure)
  • figure creates a new figure window (so a new
    plot does not replace a previous plot)
  • Formatting axes
  • xlim(0 1) sets the x-axis limits to 0 and 1
  • ylim(0 1) sets the y-axis limits to 0 and 1
  • Annotating plots
  • title(Figure Title)
  • xlabel(Label for X-axis)
  • ylabel(Label for Y-axis)
  • legend(Name of line 1,Name of line 2)

11
Plotting a Function
x 0.10.110 y1 7x./(0.6 x) y2
5x ./ (0.08x)
subplot(2,1,1) plot(x,y1) ylabel('y1')
subplot(2,1,2) plot(x,y2) ylabel('y2')
plot(x,y1,x,y2) xlabel('x') ylabel('y')
legend('y1','y2') figure
12
Matlab Exercise
  • Problem Set 8.3, Problems 20c,d
Write a Comment
User Comments (0)
About PowerShow.com