KEMBAR78
Matlab Intro | PPT
MATLAB® Introduction

             游懷祖
       AOCS/ME Dept, NSPO
         2006, March 02
捕魚的方法
• Online help:
  – http://www.mathworks.com
  – Home  Support  Product Documentation 
    “fishes” (HTML or PDF files)
• Offline help:
  – F1 key  help
  – Demos
     • Help  Demos
     • $MATLAB71/demos/*.swf (flash example movies)
  – Books
Before Getting Started…

 MATLAB: core program.
 MATLAB Toolboxes: extended
   program  M-files (or p-files).
 Simulink: GUI block diagram.
 Simulink Blocksets: extended
   Simulink.
Tonight: only (1) (75%) & (3) (25%).
Outline

• MATLAB
  – Mathematics
  – Graphics
  – Programming
• Simulink
  – Graphic User Interface (GUI) block diagram
    modeling
Integrated Design Environment
Mathematics
• Matrix-based representation
Mathematics Examples
Ex1: State transition matrix   Ex2: eigenvalue &
                               singular value decomposition
Graphics
• Basic graphic commands:




• Specialized plots & animation (make AVI movies):
  pie, histogram, contour plot, getframe, etc.
• Graphic handles: get, set commands; gcf, gca.
• Figure save, export, print, etc.
Graphic Examples
  Ex1: signal plot   Ex2: image conversion
Programming

• Data type (class):
  number (double),
  string (char), cell,
  logic, handle, etc.    Function handle Ex.

• Function handle:
  using @ or inline
  command
• Script vs. Function
• Array vs. For-loop
Programming Example (script)
Programming Example (function)
Simulink

• Choosing a solver: continuous/discrete
• Import/Export data
• Configuration sets/parameters
• Integrated with MATLAB
  workspace, M-files, C/C++  S-
  function
• Advanced level: Stateflow, Real-Time
  Workshop, xPC Target
Simulink Example
                                                              Scope
                                                          w

                  y                                                                XY Graph
     -C-          J    RotEOM y dot                                            x
                                                1
                  T                          xo s
     MOI                                                  q
                  Euler Rotational          Integrator                         y
                                                              q     tip pos
                   Eq. of motion
                                      -C- [w0,q0]                              z
                                                               body z-axis
   Pulse                                                      tip trajectory
                                                                               Terminator
  Generator




                  [0 0 1]

                      b3
                                       Matrix
                      DCM             Multiply       1
       1      q             be
                                                    tip
       q                              Product
                      q2c                           pos

  Masked subsystem

Matlab Intro

  • 1.
    MATLAB® Introduction 游懷祖 AOCS/ME Dept, NSPO 2006, March 02
  • 2.
    捕魚的方法 • Online help: – http://www.mathworks.com – Home  Support  Product Documentation  “fishes” (HTML or PDF files) • Offline help: – F1 key  help – Demos • Help  Demos • $MATLAB71/demos/*.swf (flash example movies) – Books
  • 3.
    Before Getting Started… MATLAB: core program.  MATLAB Toolboxes: extended program  M-files (or p-files).  Simulink: GUI block diagram.  Simulink Blocksets: extended Simulink. Tonight: only (1) (75%) & (3) (25%).
  • 4.
    Outline • MATLAB – Mathematics – Graphics – Programming • Simulink – Graphic User Interface (GUI) block diagram modeling
  • 5.
  • 6.
  • 7.
    Mathematics Examples Ex1: Statetransition matrix Ex2: eigenvalue & singular value decomposition
  • 8.
    Graphics • Basic graphiccommands: • Specialized plots & animation (make AVI movies): pie, histogram, contour plot, getframe, etc. • Graphic handles: get, set commands; gcf, gca. • Figure save, export, print, etc.
  • 9.
    Graphic Examples Ex1: signal plot Ex2: image conversion
  • 10.
    Programming • Data type(class): number (double), string (char), cell, logic, handle, etc. Function handle Ex. • Function handle: using @ or inline command • Script vs. Function • Array vs. For-loop
  • 11.
  • 12.
  • 13.
    Simulink • Choosing asolver: continuous/discrete • Import/Export data • Configuration sets/parameters • Integrated with MATLAB workspace, M-files, C/C++  S- function • Advanced level: Stateflow, Real-Time Workshop, xPC Target
  • 14.
    Simulink Example Scope w y XY Graph -C- J RotEOM y dot x 1 T xo s MOI q Euler Rotational Integrator y q tip pos Eq. of motion -C- [w0,q0] z body z-axis Pulse tip trajectory Terminator Generator [0 0 1] b3 Matrix DCM Multiply 1 1 q be tip q Product q2c pos Masked subsystem