Matlab - PowerPoint PPT Presentation

About This Presentation
Title:

Matlab

Description:

Matlab refresher Your objective: to dominate! My objective: to help you dominate! – PowerPoint PPT presentation

Number of Views:89
Avg rating:3.0/5.0
Slides: 12
Provided by: RCRo57
Learn more at: https://www.egr.msu.edu
Category:
Tags: matlab

less

Transcript and Presenter's Notes

Title: Matlab


1
Matlab refresher
Your objective to dominate! My objective to
help you dominate!
2
Some references
  • MATLAB Student Version Learning MATLAB, The
    MathWorks, Inc.
  • Introduction to MATLAB 6 for Engineers, W.J.Palm
    III, McGraw-Hill.
  • Numerical Methods with MATLAB, G.Recktenwald,
    Prentice Hall.

3
Key concept the Workspace (WS)
  • The Workspace (WS) contains all of your currently
    active variables and relations.
  • These are initially entered by typing commands
    (most likely).
  • Useful Workspace commands
  • Clear empty the WS
  • Who (whos) show what is in the WS
  • Save ltfilenamegt save all WS variables to file
  • Load ltfilenamegt retrieve a particular WS from
    file

4
Key concept WS inputs
Command line inputs
WORKSPACE
Script file inputs
Workspace file inputs
5
Key concept WS outputs
Diary files
WORKSPACE
Workspace files
Graphics (plot) files
6
Script files
  • Script files are text files that are created
    using the MATLAB script file editor. They usually
    have the suffix .m.
  • A script file can be run from the command line or
    toolbar.
  • Two items to remember about .m files
  • Use to enter comments for your use.
  • Use at the end of lines to suppress echo
    printing when the file is run.

7
More about the Workspace
  • Recording your MATLAB session can be useful for
    documentation.
  • Useful Workspace commands
  • Diary ltfilenamegt turn on recording of all text
    i/o except plots, save into ltfilenamegt
  • Diary off turn off current recording
  • Path pointer to current directory
  • Pathtool directory browser

8
A typical session pattern
  • Clear
  • Diary Problem1
  • create data etc here
  • Pa 14.7 R 245.6 P 23 Q (1/R)(P-Pa)
  • who
  • Save Problem1Run1
  • Diary off
  • You now have 2 files
  • Problem1 a diary of this session
  • Problem1Run1 a WS file that can be used to
    recover your last state by using a Load command

9
Solving Linear Algebraic Equations
  • Define a set of linear algebraic equations as
    follows
  • AX BU
  • X is the unknown vector (n x 1)
  • U is the input vector (m x 1)
  • A is n x n, B is n x m
  • In the WS define A, B, and U.
  • Then type X inv(A)BU

Click here to see an example session LAExample1
10
Solving Linear Algebraic Equations
  • Dominators know that a unique solution to a
    problem in linear algebra doesnt always exist.
    To investigate before you leap try this
  • Use the command det(A) to check the determinant
    of A. Proceed accordingly.
  • Sometimes we seek insight in the form of
    eigenvalues of A. Try this
  • Type Evals eig(A).

Click here to see an example session LAExample2
11
Solving Linear Differential State Equations
  • Define a set of linear algebraic equations Xdot
    AX BU
  • Xdot is the first derivative of X.
  • Create a script (.m) file that defines the
    equations for MATLAB in a specific format.
  • for example LDEEqns1.m
  • Create a script file that controls the solving of
    the problem.
  • click to see an example LDEExample.pdf
Write a Comment
User Comments (0)
About PowerShow.com