Download
announcements n.
Skip this Video
Loading SlideShow in 5 Seconds..
Announcements PowerPoint Presentation
Download Presentation
Announcements

Announcements

121 Vues Download Presentation
Télécharger la présentation

Announcements

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Announcements

  2. Matrices • Matrix – Two Dimensional Array • MatLab Creation : matrixName = [ 1,3,5;2,4,6 ]; • Row – Horizontal Values • Column – Vertical Values • Element – One Member (Value) in an Array • Offset or Subscript – For Matrix, given as Row, Column Pair (e.g., matrixName(1,2) )

  3. Matrix Creation >> matrixOne = [1,2,3;3,4,5]; >> disp(matrixOne) 1 2 3 3 4 5 >> rowV = [9, 10]; >> rowV2 = [11,12]; >> matrixTwo = [rowV;rowV2]; >> disp(matrixTwo) 9 10 11 12

  4. Matrix Addressing >> disp(matrixFour) 1 2 3 9 10 3 4 5 11 12 >> disp(matrixFour(1,1)) 1 >> disp(matrixFour(2,5)) 12 >> disp(matrixFour(-3,1)) Subscript indices must either be real positive integers or logicals. >> disp(matrixFour(1,1000)) Index exceeds matrix dimensions. >> matrixFour(1,7) = 1000; >> disp(matrixFour) 1 2 3 9 10 0 1000 3 4 5 11 12 0 0

  5. Matrix Addressing (Cont) • Colon (:) means “all” or range >> disp(matrixFour) 1 2 3 9 10 0 1000 3 4 5 11 12 0 0 >> disp(matrixFour(:,4)) 9 11 >> disp(matrixFour(2,:)) 3 4 5 11 12 0 0

  6. Matrix Addressing (Cont) >> disp(matrixFour) 1 2 3 9 10 0 1000 3 4 5 11 12 0 0 >> disp(matrixFour(:,2:5)) 2 3 9 10 4 5 11 12

  7. Matrix Scalar Operations >> disp(matrixFour) 1 2 3 9 10 0 1000 3 4 5 11 12 0 0 >> disp(matrixFour + 2) 3 4 5 11 12 2 1002 5 6 7 13 14 2 2 >> disp(matrixFour * 2) 2 4 6 18 20 0 2000 6 8 10 22 24 0 0

  8. Matrix Vector Multiplication Number of Cols in Matrix *Must* Equal Number of Rows in Vector >> matrixOne = [1,2,3;4,5,6]; >> vectorOne = [2;2;2]; >> disp(matrixOne); 1 2 3 4 5 6 >> disp(vectorOne); 2 2 2 >> disp(matrixOne * vectorOne); 12 30

  9. Matrix Matrix Multiplication Number of Cols in Left Hand Matrix *Must* Equal Number of Rows in Right Hand Matrix >> disp(matrixOne); 1 2 3 4 5 6 >> vectorOne = [2;2;2]; >> matrixTwo = [vectorOne, vectorOne * 2]; >> disp(matrixTwo); 2 4 2 4 2 4 >> disp(matrixOne * matrixTwo); 12 24 30 60

  10. Matrix Matrix Multiplication Number of Cols in Left Hand Matrix *Must* Equal Number of Rows in Right Hand Matrix >> disp(matrixOne); 1 2 3 4 5 6 >> disp(matrixTwo); 2 4 2 4 2 4 >> disp(matrixTwo * matrixOne); 18 24 30 18 24 30 18 24 30

  11. >> matrixTwo = [matrixTwo; [1,1]]; >> disp(matrixTwo); >> disp(matrixOne); 2 4 1 2 3 2 4 4 5 6 2 4 1 1 >> disp(matrixTwo * matrixOne); 18 24 30 18 24 30 18 24 30 5 7 9 >> disp(matrixOne * matrixTwo); Error using * Inner matrix dimensions must agree.

  12. >> matrixThree = [2,2;1,1]; >> disp(matrixThree); 2 2 1 1 >> matrixFour = [3,4;5,6] >> disp(matrixFour); 3 4 5 6 >> disp(matrixThree .* matrixFour); 6 8 5 6 >> disp(matrixThree * matrixFour); 16 20 8 10

  13. Matrix Exponenent >> disp(matrixTwo) 1 2 3 4 5 6 7 8 9 >> disp(matrixTwo.^2) 1 4 9 16 25 36 49 64 81 >> disp(matrixTwo^2) 30 36 42 66 81 96 102 126 150

  14. Matrix Functions >> disp(matrixFive); 9 3 5 0 8 -9 11 16 >> disp(sum(matrixFive)) 17 -6 16 16 >> disp(sum(sum(matrixFive))) 43

  15. Matrix Functions >> disp(matrixFive); 9 3 5 0 8 -9 11 16 >> disp(max(matrixFive)); 9 3 11 16 >> disp(min(matrixFive)); 8 -9 5 0 >> disp(max(max(matrixFive))); 16

  16. Matrix Functions >> disp(matrixFive); 9 3 5 0 8 -9 11 16 >> disp(length(matrixFive)) 4 >> disp(size(matrixFive)) 2 4 >> disp(sort(matrixFive)) 8 -9 5 0 9 3 11 16

  17. Matrix Functions >> disp(vectorOne); 1 2 3 4 5 6 7 8 9 10 >> disp(vectorTwo); 1 4 9 16 25 36 49 64 81 100 >> plot (vectorOne, vectorTwo)

  18. >> disp(vectorOne); 1 2 3 4 5 6 7 8 9 10 >> disp(vectorTwo); 1 4 9 16 25 36 49 64 81 100 >> plot (vectorOne, vectorTwo)

  19. More MatLab • Plotting • Setting Axes, Grid Marks • Labels • Plotting Functions • Labeling • Files • Data Files • Spreadsheet Files • Statistics, Probablity, Higher Math • Random Numbers • Normal Distribution • Linear Equations • Calculus