??????????????? MATLAB ????????? - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

??????????????? MATLAB ?????????

Description:

matlab . – PowerPoint PPT presentation

Number of Views:101
Avg rating:3.0/5.0
Slides: 28
Provided by: Song105
Category:

less

Transcript and Presenter's Notes

Title: ??????????????? MATLAB ?????????


1
??????????????? MATLAB ?????????
  • ??.???????? ???????????
  • charturong.ee.engr.tu.ac.th/CN208
  • ??????????????????????????????????
  • ?????????????????????

????????????????????????????? ??.????? ??????????
2
What is MATLAB?
  • MATLAB ???????? MATrix LABoratory
    ???????????????????????????????????????????
    ???????????
  • Math and computation
  • Algorithm development
  • Data acquisition
  • Modeling, simulation, and prototyping
  • Data analysis, exploration, and visualization
  • Scientific and engineering graphics
  • Application development, including graphic user
    interface building

3
???????? MATLAB
3
1
2
4
  • The Command Window
  • ?????????? commands ??????????????????????????????
    ?????? gtgt (the command prompt) ???????????????????
    ??????????? commands ????????????????? Enter
    ????????????
  • 2. The Command History Window
  • ?????????? the command history ???????????????????
    ???????????????????????????????? (The Command
    History) ?????????????????????????? MATLAB
  • 3. The Current Directory
  • ?????????????????????????????????? MATLAB
    ?????????????????? (Directory) ??????? ????????
    MATLAB ???????????????? Directory ??????????????
    ???????????????????????? (Browse) ????
    ???????????????? the Current Directory ???

5
To get Help
  • MATLAB ?????????? Help ???????????????????????????
    ????????? ????????????????????????????????????????
    ?? ????
  • ?????????? ? ??????? Current Directory
  • ???? 2. ????? helpdesk ???? helpwin ??? command
    prompt (gtgt) ?????????? Command ?????? Enter

6
???????? Help
7
  • ?????????? Help ??????????????????????????????????
    4 ??????????????
  • Contents ?????????????????????????????????? ???
    ????? Toolbox ?????
  • Index ????????????? Function ??? MATLAB
    ???????????? A-Z
  • Search ?????????????? Function ??????? MATLAB
  • Demos ???????????????????????????????????? MATLAB
  • ??? MATLAB
  • ?????????????? MATLAB ??????????????????? exit
    ???? quit ??? command prompt ?????????? command

8
Simple Math
  • MATLAB ????????????????????????????????????????
    ???????????????????????????????????????
  • ??????????????????????
  • ???????? (2525-93)/2 ???? command prompt (gtgt)
  • ??????????????????? 15

9
Special Symbols
Operation Symbol
Addition Subtraction Multiplication Division Exponentation - /
10
?????? ???? Variable
  • ?????? (variable) ????????????????????????????????
    ?????? ???????????????????????????????????????????
    ????????????????????????????? command
    ????????????
  • ??????????????? var ???????? 15 ????????????????
    gtgtvar 15 ??? command window

11
??????????????????????
  • ???????? MATLAB ????????????????????????????????
    ???????????????????????? ??? ????
    ????????????????????? ( _ ) ????????
    ?????????????????????????? 63 ????????
  • ???????????????????????????????????????? index,
    year, growth_rate, a1, a2 ???????
  • ???????????????????????????? growth rate
    (???????????????), 2r (?????????????????????)
  • ???????? ???????? MATLAB ???? case-sensitive
    ??????? MATLAB ?????????????? Growth
    ???????????????????? growth
  • ??????? ????????????????????????????????????????
    (lower-case letters) ??????????????????????

12
Assignment Statements
  • ???????????????????????????????????????
  • var expression
  • ??????? ??????????????????????????????????????
    ???? ??? MATLAB ???????????? expression
    ????????????????????? ????????????????????????????
    ?????? var
  • ????????
  • gtgt gas 29 ? ?????? gas ???? 29
  • gtgt gas gas 1 ? ?????? gas ??????????? 30
  • gtgt gas 1 30 ? ERROR

13
Data Type
  • ??????????????? MATLAB ????????????? double ????
    char
  • ?????????? double ?????????????????????? (scalar)
    ????????????? 64 bits ????????????????????????????
    ???????????????????? 10-308 ??? 10308
    ???????????????????????????? 15
  • MATLAB ???????????????????????? double
    ???????????????????????????
  • ?????????? char ????????? 16 bits
    ???????????????????????????????????
    ??????????????????????????? MATLAB
    ?????????????????????? array ??? char
    ??????????????
  • gtgtcomment 'This is a character string'
  • ???????????????? comment ??????? array ???
    character 26 ???

14
MATLAB Matrices 1
  • ??????????????????????????????????????????????????
  • 1. ?????????? element ???????????????????????????
  • 2. ???????????(space)??????????(comma)???????????
    ????????????? (row)
  • 3. ?????????????? semicolon ()
    ????????????????????????????
  • 4. ????????????????????????????????
  • ??????????????

15
MATLAB Matrices 2
  • ???????????????? MATLAB ??????????????????????????
    ?????? Enter ???? ?????? semicolon
    ??????????????????????????
  • ?????? MATLAB ????????????????????????????????????
    ????????????? ????????????????????????????????????
    ???????????????????? (debug) ??????????????????

16
???????????????????????????
  • ????????????????? a ???
  • ???????????????????? a ?? row ??? 2 ??? column
    ??? 4 ????????????????????
  • ??????????????????????????????????????????????????
    ? ?????????????????????????????????????
    ?????????????????? comma ????????????????????
    column
  • ??????????????????? a ?? row ??? 3 ??? column ???
    5 ??????????? gtgt a(3,5) ???????

17
?????????????????????????????
  • ????????????????????????????? ????????????????????
    ??????????????????????????????????????????? 12
    ???????????????????????????????????????????? ???
    ??????????????????????????????????????????? ()
    ?????????????? ???????????????????????????????? 2
    ?????????? 3 ??????????? a ???????????????????????
    ?? 0 ???????????????????????
  • ???????????????????????? a ???????? 2 ??????????
    3 ????????????? 8 ???? 0

18
The Colon () Operator
  • The colon operator ???????????????? list
    ?????????????????????????????????????????????
    ????????????????????????????????????????
    ????????????????? colon ????????
  • firstincrlast
  • ?????? first ??????????????????????? incr
    ?????????????????????? ??? last
    ??????????????????????? ??????????????
  • gtgt 129
  • MATLAB ???????????
  • ans 1 3 5 7 9
  • ??????? ???????????????? 1 ????????????? 2
    ???????? 9
  • ????????? incr ??? 1 ?????????????????????????????
    ??????? ???????????????????????????
  • gtgt 58
  • MATLAB ???????????
  • ans 5 6 7 8

19
?????? colon ???????????????????
  • ???????? a ???
  • ???????????????? b ??????????????????????????? a
    ??? row ??? 2 ??? column ??? 3 ?????????
    ?????????
  • ???? 23 ????????????????????? 2 ????????? 3 ???
    35 ????????????? 3, 4, ??? 5
  • ??????????????????????????? gtgt b a(2 3,3 4
    5) ????????????????????????

20
  • ??????????????????????????????????????????????????
    ????? ????????????????? colon ?????????????
    ??????????????
  • gtgt a(2, ) 5 ??????????????????????????
    ? row 2 ?????????? a ???? 5
  • ??????????????? ????????????????????????????
    1 ????????????????? ??????? ????????? a ?????? 2
    ?????????? 1 ?????????????????????????? 5
  • gtgt a(, 3) -1 ??????????????????????????
    ? column 3 ?????????? a ???? -1
  • ??????????? ?????????????????????? 1
    ????????????? ??????? ????????? a ?????? 1
    ????????????? ?????????? 3 ??????????? -1

21
The end Function
  • MATLAB ???????????????????? end
    ?????????????????????????????????? ????????? end
    ???????????????????????????????????????????????
    ??????????????
  • ???
  • gtgt b a(2end, 3end)
  • ???????????????????????????????????????? 19
    ?????? end ????????????????? 3 ???????????????????
    ???????????? a ???? end ???????????????????? 5
    ??????????????????????????????????? a

22
Vector
  • ???????? (vector) ????????????? subset
    ??????????? ?????????????????????????????? 1
  • ??????????????
  • ????? row vector c ????????? array ???? 1x3
    ??????????? 3 ???????? 1.0, 2.5, ??? 3.0
    ????????

  • ?????????????? column vector d ????????? array

  • ???? 3x1 ??????????? 3 ????? ???????

23
????????????????????????
  • ??????????????????????????????????????????????????
    ???????????????????????? ??????????????
  • gtgta 1 3 5 8 9
  • ?????????????????????????? 3 ??????????? a
    ???????????????
  • gtgta(3) ???? gtgta(1, 3)
  • ??????????????????? ans 5
  • ??????????????????????????? a ????????????????
  • gtgta(end) ???? gtgt a(5) ???? gtgta(1, 5)
  • ??????????????????? ans 9

24
Transpose Operator (')
  • Transpose operator (') ???????????????????????????
    ??????????????????? ??????????????
  • gtgt f 14 ???? MATLAB ???????? f
    ???? row vector ???? 1x4
  • f 1 2 3 4
  • ???? transpose ???????? f ???????????????????????
  • ????????
    column vector ???? 4x1

25
?????????????????????????????????
  • ??????????????????????????????????????????????????
    ???(????????????)??????????? ???????????
  • gtgt g 1 3 2 7
  • gtgt b 4 9
  • gtgt h g b
  • ???????????????
  • gtgt m b' g
  • ???????????????

26
????????????????????????????????
  • ?????????????????????????????????????????????? an
    empty array ????????????
  • ????????????????????????? 2 ???????????
    ????????????????????
  • gtgt h(, 2)
  • ???? MATLAB ???????????????????? h ????????
  • ????????????????? h ??????????????? 2x2
  • ??????????????????????????????????? ??????????? a
    ?? 5 ?????????????????
  • gtgta 3 9 0 1 5
  • ??????????????????????????? 1 ???????????????????
  • gtgta(1)
  • ???? MATLAB ???????????????????? h ???????? a
    9 0 1 5

27
MATLAB Functions for Initializing Variables
Function Purpose
zeros(n) zeros(n,m) zeros(size(arr)) ones(n) ones(n,m) ones(size(arr)) eye(n) eye(n,m) length(arr) size(arr) Generates an n n matrix of zeros Generates an n m matrix of zeros Generates a matrix of zeros of the same size as arr Generates an n n matrix of ones Generates an n m matrix of ones Generates a matrix of ones of the same size as arr Generates an n n identity matrix Generates an n m identity matrix Returns the length of a vector, or the longest dimension of a 2-D array Returns two values specifying the number of rows and columns in arr
Write a Comment
User Comments (0)
About PowerShow.com