2 ArrayMatrix 2252021 Puff The magic dragon live

  • Slides: 83
Download presentation
第 2 章 陣列(Array)與矩陣(Matrix) 的運算 2/25/2021 Puff! The magic dragon, live by the sea…

第 2 章 陣列(Array)與矩陣(Matrix) 的運算 2/25/2021 Puff! The magic dragon, live by the sea… 1

2/25/2021 Puff! The magic dragon, live by the sea… 2

2/25/2021 Puff! The magic dragon, live by the sea… 2

列向量 & 行向量 • Row vector 列向量 [5, 7, 2]; [3, 4, -6, 7]

列向量 & 行向量 • Row vector 列向量 [5, 7, 2]; [3, 4, -6, 7] • Column vector 行向量 2/25/2021 Puff! The magic dragon, live by the sea… 3

陣 列 Arrays 2/25/2021 Puff! The magic dragon, live by the sea… 4

陣 列 Arrays 2/25/2021 Puff! The magic dragon, live by the sea… 4

轉置 transpose 2/25/2021 Puff! The magic dragon, live by the sea… 5

轉置 transpose 2/25/2021 Puff! The magic dragon, live by the sea… 5

Transpose matrix • g=[1; 2; 3; 4]; g 1=g’; or g=[1 2 3 4];

Transpose matrix • g=[1; 2; 3; 4]; g 1=g’; or g=[1 2 3 4]; 2/25/2021 Puff! The magic dragon, live by the sea… 6

Transpose matrix • k=[1 -9 1 0 3; -4 4 1 1 2; 24

Transpose matrix • k=[1 -9 1 0 3; -4 4 1 1 2; 24 2 2 36 2] or k=[1, -9, 1, 0, 3; -4, 4, 1, 1, 2; 24, 2, 2, 36, 2] or k=[1 -9 1 0 3 -4 4 1 1 2 24 2 2 36 2] • k 1=k’ 2/25/2021 Puff! The magic dragon, live by the sea… 7

產生等間距大向量 x=[m: q: n] ? x=[0: 2: 8] x= 0 2 4 • ?

產生等間距大向量 x=[m: q: n] ? x=[0: 2: 8] x= 0 2 4 • ? y=[-3: 2] • y= • -3 -2 -1 2/25/2021 6 8 0 1 2 Puff! The magic dragon, live by the sea… 8

產生等間距大向量 ? z=[0: 0. 1: 2] z= Columns 1 through 7 0 0. 1000

產生等間距大向量 ? z=[0: 0. 1: 2] z= Columns 1 through 7 0 0. 1000 0. 2000 0. 3000 0. 4000 0. 5000 0. 6000 Columns 8 through 14 0. 7000 0. 8000 0. 9000 1. 0000 1. 1000 1. 2000 1. 3000 1. 7000 1. 8000 1. 9000 2. 0000 Columns 15 through 21 1. 4000 2/25/2021 1. 5000 1. 6000 Puff! The magic dragon, live by the sea… 9

產生等間距大向量 ? zzz=[3: -0. 5: 0] zzz = 3. 0000 2/25/2021 2. 5000 2.

產生等間距大向量 ? zzz=[3: -0. 5: 0] zzz = 3. 0000 2/25/2021 2. 5000 2. 0000 1. 5000 1. 0000 Puff! The magic dragon, live by the sea… 0. 5000 0 10

linespace(x 1, x 2, n) 產生等間距列向量 • linespace(5, 8, 31) • the same as

linespace(x 1, x 2, n) 產生等間距列向量 • linespace(5, 8, 31) • the same as [5: 0. 1: 8] • n 表示列向量內含的元素個數 如果省略則 內定值為 1 2/25/2021 Puff! The magic dragon, live by the sea… 11

logspace(x 1, x 2, n) 產生具有對數等間距的向量 • logspace (a, b, n) • 在 10

logspace(x 1, x 2, n) 產生具有對數等間距的向量 • logspace (a, b, n) • 在 10 a~10 b間(含)取的點數 • logspace(-1, 1, 4)=[0. 1, 0. 4642, 2. 1544, 10. 0] 2/25/2021 Puff! The magic dragon, live by the sea… 12

2 -Dimensional Arrays 2/25/2021 Puff! The magic dragon, live by the sea… 13

2 -Dimensional Arrays 2/25/2021 Puff! The magic dragon, live by the sea… 13

合併 矩陣(行數增加) ? A=[2, 4, 10; 16, 3, 7] A= 2 4 10 16

合併 矩陣(行數增加) ? A=[2, 4, 10; 16, 3, 7] A= 2 4 10 16 3 7 ? r=[1, 1; 0, 0] r= 1 1 0 0 ? B=[A r] B= 2 4 10 1 1 16 3 7 0 0 2/25/2021 矩陣A與r需具有相同的 列數 Puff! The magic dragon, live by the sea… 14

合併 矩陣(列數增加) ? A=[2, 4, 10; 16, 3, 7] A= 2 4 10 16

合併 矩陣(列數增加) ? A=[2, 4, 10; 16, 3, 7] A= 2 4 10 16 3 7 ? r=[1, 2, 3] r= 1 2 3 ? B=[A; r] 矩陣A與r需具有相同的 行數 B= 2 16 1 2/25/2021 4 10 3 7 2 3 Puff! The magic dragon, live by the sea… 15

Transpose matrix (complex conjugate) ? A=[3+2*i, 2+6*i; 5+4*i, 3+5*i] A= 3. 0000 + 2.

Transpose matrix (complex conjugate) ? A=[3+2*i, 2+6*i; 5+4*i, 3+5*i] A= 3. 0000 + 2. 0000 i 2. 0000 + 6. 0000 i 5. 0000 + 4. 0000 i 3. 0000 + 5. 0000 i ? A' ans = 3. 0000 - 2. 0000 i 5. 0000 - 4. 0000 i 2. 0000 - 6. 0000 i 3. 0000 - 5. 0000 i 2/25/2021 Puff! The magic dragon, live by the sea… 16

Array addressing定址 1. 修改矩陣內元素 D(1, 3)=6 B= 2 4 10 16 3 7 1

Array addressing定址 1. 修改矩陣內元素 D(1, 3)=6 B= 2 4 10 16 3 7 1 2 3 ? B(2, 2)=0 B= 2 4 10 16 0 7 1 2 3 2/25/2021 Puff! The magic dragon, live by the sea… 17

Array addressing定址 2. V(: ) V向量內所有元素 ? V=[1 2 3 4 5] V= 1

Array addressing定址 2. V(: ) V向量內所有元素 ? V=[1 2 3 4 5] V= 1 2 3 4 5 ? V(: ) ans = 1 2 3 4 5 2/25/2021 Puff! The magic dragon, live by the sea… 18

Array addressing定址 3. V(2: 4) • • • V= 1 2 ? V(2: 4)

Array addressing定址 3. V(2: 4) • • • V= 1 2 ? V(2: 4) ans = 2 3 V(2), V(3), V(4), V(5), V(6) 2/25/2021 3 4 5 4 Puff! The magic dragon, live by the sea… 19

Array addressing定址 4. A(: , 3) A= 3 5 17 1 2 3 ?

Array addressing定址 4. A(: , 3) A= 3 5 17 1 2 3 ? A(: , 3) ans = 11 8 4 2/25/2021 矩陣A第三行所有的元素 11 8 4 Puff! The magic dragon, live by the sea… 20

Array addressing定址 5. A(: , 2: 3) 矩陣A第 2行至第 3行所有的元素 A= 3 5 11

Array addressing定址 5. A(: , 2: 3) 矩陣A第 2行至第 3行所有的元素 A= 3 5 11 17 1 8 2 3 4 ? A(: , 2: 3) ans = 5 11 1 8 3 4 2/25/2021 Puff! The magic dragon, live by the sea… 21

Array addressing定址 6. A(2: 3, 1: 3)矩陣A第 2至第 3列, 第 1至第 3行所有的元 素 (可用以分割矩陣)

Array addressing定址 6. A(2: 3, 1: 3)矩陣A第 2至第 3列, 第 1至第 3行所有的元 素 (可用以分割矩陣) A= 3 5 11 17 1 8 2 3 4 ? A(2: 3, 2: 3) ans = 1 8 3 4 2/25/2021 Puff! The magic dragon, live by the sea… 22

? A=[6, 9, 4; 1, 5, 7] A= 6 9 4 1 5 7

? A=[6, 9, 4; 1, 5, 7] A= 6 9 4 1 5 7 ? A(1, 5)=3 A= 6 9 4 0 3 1 5 7 0 0 ? B=A(: , 5: -1: 1) %把A陣列行排列的次序顛倒過來 B= 3 0 4 9 6 0 0 7 5 1 2/25/2021 Puff! The magic dragon, live by the sea… 23

B= 3 0 4 9 6 0 0 7 5 1 C= -4 12

B= 3 0 4 9 6 0 0 7 5 1 C= -4 12 3 5 8 ? B(2, : )=C B= 3 0 4 9 6 -4 12 3 5 8 2/25/2021 Puff! The magic dragon, live by the sea… 24

? D=[3, 8, 5; 2, -6, 9] D= 3 8 5 2 -6 9

? D=[3, 8, 5; 2, -6, 9] D= 3 8 5 2 -6 9 ? E=D([2, 2, 2, 1], : ) %將陣列D的第二列重複三次, 第一列重複一次 E= 2 -6 9 3 8 5 2/25/2021 Puff! The magic dragon, live by the sea… 25

Using ‘clear’ to avoid errors • clear A 2/25/2021 Puff! The magic dragon, live

Using ‘clear’ to avoid errors • clear A 2/25/2021 Puff! The magic dragon, live by the sea… 26

A= 6 9 4 1 5 7 ? max(A) ans = 6 9 7

A= 6 9 4 1 5 7 ? max(A) ans = 6 9 7 ? [x, k]=max(A) x= 6 9 7 k = % index 1 1 2 2/25/2021 0 0 3 0 3 1 1 Puff! The magic dragon, live by the sea… 27

 • B= • 6 9 4 0 3 • ? max(B) • ans

• B= • 6 9 4 0 3 • ? max(B) • ans = • 9 2/25/2021 Puff! The magic dragon, live by the sea… 28

? A=[6 2; -10 -5; 3 0] A= 6 2 -10 -5 3 0

? A=[6 2; -10 -5; 3 0] A= 6 2 -10 -5 3 0 ? max(A) ans = 6 2 ? min(A) ans = -10 -5 ? size(A) ans = 3 2 ? length(A) ans = 3 2/25/2021 %傳回m*n (3*2)中的最大值 Puff! The magic dragon, live by the sea… 29

? A=[6 2; -10 -5; 3+4*i 0] A= 6. 0000 2. 0000 -10. 0000

? A=[6 2; -10 -5; 3+4*i 0] A= 6. 0000 2. 0000 -10. 0000 -5. 0000 3. 0000 + 4. 0000 i 0 ? max(A) ans = -10 -5 ? min(A) ans = 3. 0000 + 4. 0000 i 0 2/25/2021 Puff! The magic dragon, live by the sea… 30

A= 6. 0000 2. 0000 -10. 0000 -5. 0000 3. 0000 + 4. 0000

A= 6. 0000 2. 0000 -10. 0000 -5. 0000 3. 0000 + 4. 0000 i 0 ? sum(A) %將同一行中的所有元素加總 ans = -1. 0000 + 4. 0000 i -3. 0000 2/25/2021 Puff! The magic dragon, live by the sea… 31

A= 6. 0000 2. 0000 -10. 0000 -5. 0000 3. 0000 + 4. 0000

A= 6. 0000 2. 0000 -10. 0000 -5. 0000 3. 0000 + 4. 0000 i 0 ? sort(A) %依同行中元素大小順序排列 ans = 3. 0000 + 4. 0000 i 0 6. 0000 2. 0000 -10. 0000 -5. 0000 2/25/2021 Puff! The magic dragon, live by the sea… 32

2/25/2021 Puff! The magic dragon, live by the sea… 33

2/25/2021 Puff! The magic dragon, live by the sea… 33

2/25/2021 Puff! The magic dragon, live by the sea… 34

2/25/2021 Puff! The magic dragon, live by the sea… 34

2/25/2021 Puff! The magic dragon, live by the sea… 35

2/25/2021 Puff! The magic dragon, live by the sea… 35

Magnitude, length, and absolute value of a Vector • Self testing p. 79 2/25/2021

Magnitude, length, and absolute value of a Vector • Self testing p. 79 2/25/2021 Puff! The magic dragon, live by the sea… 36

多維陣列multidimensional arrays • m*n*q • m: 列(row), n: 行(column), q: 頁(page) • 第n頁的所有元素 A(:

多維陣列multidimensional arrays • m*n*q • m: 列(row), n: 行(column), q: 頁(page) • 第n頁的所有元素 A(: , n) 2/25/2021 Puff! The magic dragon, live by the sea… 37

? A=[4, 6, 1; 5, 8, 0; 3, 9, 2] A= 4 6 1

? A=[4, 6, 1; 5, 8, 0; 3, 9, 2] A= 4 6 1 5 8 0 3 9 2 ? A(: , 2)=[6, 2, 9; 0, 3, 1; 4, 7, 5] A(: , 1) = 4 6 1 5 8 0 3 9 2 A(: , 2) = 6 2 9 0 3 1 4 7 5 2/25/2021 Puff! The magic dragon, live by the sea… 38

? A=[8 2; 9 5] A= 8 2 9 5 ? B=[4 6; 7

? A=[8 2; 9 5] A= 8 2 9 5 ? B=[4 6; 7 3] B= 4 6 7 3 ? C=cat(3, A, B) C(: , 1) = 8 2 9 5 C(: , 2) = 4 6 7 3 2/25/2021 Puff! The magic dragon, live by the sea… 39

cat(1, A, B)=[A; B] 一維 A= 8 2 9 5 B= 4 6 7

cat(1, A, B)=[A; B] 一維 A= 8 2 9 5 B= 4 6 7 3 ? cat(1, A, B) ans = 8 2 9 5 4 6 7 3 2/25/2021 ? [A; B] ans = 8 2 9 5 4 6 7 3 Puff! The magic dragon, live by the sea… 40

cat(2, A, B)=[A, B] 二維 A= 8 9 B= 4 7 2 5 6

cat(2, A, B)=[A, B] 二維 A= 8 9 B= 4 7 2 5 6 3 ? cat(2, A, B) ans = 8 2 4 9 5 7 2/25/2021 ? [A, B] ans = 8 2 9 5 4 7 6 3 Puff! The magic dragon, live by the sea… 41

cat(3, A, B) 三維 A= 8 2 9 5 B= 4 6 7 3

cat(3, A, B) 三維 A= 8 2 9 5 B= 4 6 7 3 ? cat(3, A, B) ans(: , 1) = 8 2 9 5 2/25/2021 ans(: , 2) = 4 6 7 3 ? C(2, 1, 1) ans = 9 Puff! The magic dragon, live by the sea… 42

Array Operations A= 8 9 ? 3*A ans = 24 27 2/25/2021 2 5

Array Operations A= 8 9 ? 3*A ans = 24 27 2/25/2021 2 5 6 15 ? A+1000 ans = 1008 1009 ? A/3 ans = 2. 6667 3. 0000 1002 1005 0. 6667 1. 6667 Puff! The magic dragon, live by the sea… B= 4 6 7 3 ? A+B ans = 12 8 16 8 ? A-3*B ans = -4 -16 -12 -4 43

A= 8 2 9 5 B= 4 6 7 3 • ? A*B ans

A= 8 2 9 5 B= 4 6 7 3 • ? A*B ans = 46 54 71 69 ? A. *B ans = 32 12 63 15 2/25/2021 Array Operations ? A. /B %(B. A) ans = 2. 0000 0. 3333 1. 2857 1. 6667 ? AB %(A-1*B) ans = 0. 2727 1. 0909 0. 9091 -1. 3636 ? B. /A %(A. B) ans = 0. 5000 3. 0000 0. 7778 0. 6000 ? A/B %(A*B-1) ans = -0. 3333 1. 3333 0. 2667 1. 1333 Puff! The magic dragon, live by the sea… 44

2/25/2021 Puff! The magic dragon, live by the sea… 45

2/25/2021 Puff! The magic dragon, live by the sea… 45

2/25/2021 Puff! The magic dragon, live by the sea… 46

2/25/2021 Puff! The magic dragon, live by the sea… 46

2/25/2021 Puff! The magic dragon, live by the sea… 47

2/25/2021 Puff! The magic dragon, live by the sea… 47

Take a rest! Try p. 84 ex. 2. 3 -1 2/25/2021 Puff! The magic

Take a rest! Try p. 84 ex. 2. 3 -1 2/25/2021 Puff! The magic dragon, live by the sea… 48

? x=[2, 4, -5]; y=[-7, 3, -8] ? x. *y ans = -14 12

? x=[2, 4, -5]; y=[-7, 3, -8] ? x. *y ans = -14 12 40 ? x*y ? ? ? Error using ==> * Inner matrix dimensions must agree. 2/25/2021 ? x'*y ans = -14 6 -16 -28 12 -32 35 -15 40 ? x*y' ans = 38 Puff! The magic dragon, live by the sea… 49

p. 86, ex. 2. 3 -2 ? v=w-r v= -75 23 -10 ? r=[55,

p. 86, ex. 2. 3 -2 ? v=w-r v= -75 23 -10 ? r=[55, 36, 25]; ? w=[-20, 59, 15]; ? dist 1=sqrt(sum(r. *r)) dist 1 = 70. 327 2/25/2021 ? dist 2=sqrt(sum(v. *v)) dist 2 = 79. 0822 Puff! The magic dragon, live by the sea… 50

Ex. 2. 3 -3 ? t=[0: . 003: 0. 5]; ? y=exp(-8*t). *sin(9. 7*t+pi/2);

Ex. 2. 3 -3 ? t=[0: . 003: 0. 5]; ? y=exp(-8*t). *sin(9. 7*t+pi/2); ? plot(t, y), xlabel('t (sec)'), . . . ylabel('y(t)') 2/25/2021 Puff! The magic dragon, live by the sea… 51

p. 89, ex. 2. 3 -4 ? d=[560, 440, 490, 530, 370] %mile ?

p. 89, ex. 2. 3 -4 ? d=[560, 440, 490, 530, 370] %mile ? t=[10. 3, 8. 2, 9. 1, 10. 1, 7. 5] % hour ? speed=d. /t speed = 54. 3689 53. 6585 53. 8462 52. 4752 49. 3333 2/25/2021 Puff! The magic dragon, live by the sea… 52

Array exponentiation ? A=[4 -5; 2 3] A= 4 -5 2 3 ? B=A.

Array exponentiation ? A=[4 -5; 2 3] A= 4 -5 2 3 ? B=A. ^3 B= 64 -125 8 27 2/25/2021 ? C=3. ^A C= 81. 0000 0. 0041 9. 0000 27. 0000 Puff! The magic dragon, live by the sea… 53

I=V/R, P=V^2/R ? R=[10000, 20000, 35000, 100000, 200000]; ? V=[120, 80, 110, 200, 350];

I=V/R, P=V^2/R ? R=[10000, 20000, 35000, 100000, 200000]; ? V=[120, 80, 110, 200, 350]; ? current=V. /R current = 0. 0120 0. 0040 0. 0031 0. 0020 0. 0018 ? power=V. ^2. /R power = 1. 4400 0. 3200 0. 3457 0. 4000 0. 6125 2/25/2021 Puff! The magic dragon, live by the sea… 54

? x=[0: . 001: 0. 6]; ? L=100*(x/0. 6). ^(0. 625). *((1 -x)/0. 4).

? x=[0: . 001: 0. 6]; ? L=100*(x/0. 6). ^(0. 625). *((1 -x)/0. 4). ^(-1. 625); ? plot(L, x), grid, xlabel('L (mol)'), . . . ylabel('x (mol B/mol)'), [L, x]=ginput(1) L= 70. 0461 x= 0. 5219 2/25/2021 Puff! The magic dragon, live by the sea… 55

Multivariable functions • • • Ex-2. 3 -7 v=10, 12, 14, 16, 18, 20

Multivariable functions • • • Ex-2. 3 -7 v=10, 12, 14, 16, 18, 20 m/s =50, 60, 70, 80 degrees • • • • g=9. 8; v=[10: 2: 20]; th=[50: 10: 80] thr=th*(pi/180); vel=[ ]; for k=1: length(th) vel=[vel, v']; end theta=[ ]; for k=1: length(v) theta=[theta; thr]; end h=(vel. ^2. *(sin(theta)). ^2)/(2. *g) H=[v', h]; table=[0, th; H] 2/25/2021 Puff! The magic dragon, live by the sea… 56

 • 0 50. 0000 60. 0000 70. 0000 80. 0000 • 10. 0000

• 0 50. 0000 60. 0000 70. 0000 80. 0000 • 10. 0000 2. 9940 3. 8265 4. 5052 4. 9482 • 12. 0000 4. 3114 5. 5102 6. 4875 7. 1254 • 14. 0000 5. 8682 7. 5000 8. 8302 9. 6985 • 16. 0000 7. 6646 9. 7959 11. 5334 12. 6674 • 18. 0000 9. 7006 12. 3980 14. 5969 16. 0322 • 20. 0000 11. 9760 15. 3061 18. 0209 19. 7928 2/25/2021 Puff! The magic dragon, live by the sea… 57

Ax=b 2/25/2021 Puff! The magic dragon, live by the sea… 58

Ax=b 2/25/2021 Puff! The magic dragon, live by the sea… 58

2/25/2021 Puff! The magic dragon, live by the sea… 59

2/25/2021 Puff! The magic dragon, live by the sea… 59

2/25/2021 Puff! The magic dragon, live by the sea… 60

2/25/2021 Puff! The magic dragon, live by the sea… 60

2/25/2021 Puff! The magic dragon, live by the sea… 61

2/25/2021 Puff! The magic dragon, live by the sea… 61

Matrix operation • • • Multiplication of vectors p. 95 Vector-matrix multiplication p. 96

Matrix operation • • • Multiplication of vectors p. 95 Vector-matrix multiplication p. 96 Matrix-matrix multiplication p. 96 The general matrix multiplication case p. 99 2/25/2021 Puff! The magic dragon, live by the sea… 62

2/25/2021 Puff! The magic dragon, live by the sea… 63

2/25/2021 Puff! The magic dragon, live by the sea… 63

2/25/2021 Puff! The magic dragon, live by the sea… 64

2/25/2021 Puff! The magic dragon, live by the sea… 64

2/25/2021 Puff! The magic dragon, live by the sea… 65

2/25/2021 Puff! The magic dragon, live by the sea… 65

Special matrices • Null matrix • Identity matrix 2/25/2021 Puff! The magic dragon, live

Special matrices • Null matrix • Identity matrix 2/25/2021 Puff! The magic dragon, live by the sea… 66

Special matrices • ? eye(3) • ? ones(3) • ans = • • •

Special matrices • ? eye(3) • ? ones(3) • ans = • • • 2/25/2021 1 0 0 0 1 • • • Puff! The magic dragon, live by the sea… 1 1 1 1 1 67

Special matrices • ? zeros(3) • ? zeros(2, 3) • ans = • •

Special matrices • ? zeros(3) • ? zeros(2, 3) • ans = • • • 2/25/2021 0 0 0 0 0 • • Puff! The magic dragon, live by the sea… 0 0 0 68

Special products • cross(A, B) ~ momentum • dot(r, F) 2/25/2021 Puff! The magic

Special products • cross(A, B) ~ momentum • dot(r, F) 2/25/2021 Puff! The magic dragon, live by the sea… 69

2/25/2021 Puff! The magic dragon, live by the sea… 70

2/25/2021 Puff! The magic dragon, live by the sea… 70

2/25/2021 Puff! The magic dragon, live by the sea… 71

2/25/2021 Puff! The magic dragon, live by the sea… 71

polyminals • [a 1, a 2, … an-1, an+1] 2/25/2021 Puff! The magic dragon,

polyminals • [a 1, a 2, … an-1, an+1] 2/25/2021 Puff! The magic dragon, live by the sea… 72

Polynomial algebra • f=[9, -5, 3, 7] • g=[6, -1, 2] • g=[0 g]=[0,

Polynomial algebra • f=[9, -5, 3, 7] • g=[6, -1, 2] • g=[0 g]=[0, 6, -1, 2] • h=f+g=[9, 1, 2, 9] 2/25/2021 Puff! The magic dragon, live by the sea… 73

Polynomial algebra • • • f(x)g(x)=? ? f=[9, -5, 3, 7] ? g=[6, -1,

Polynomial algebra • • • f(x)g(x)=? ? f=[9, -5, 3, 7] ? g=[6, -1, 2] ? product= conv(f, g) product = 54 -39 41 29 2/25/2021 -1 14 Puff! The magic dragon, live by the sea… 74

Polynomial algebra • • f(x)/g(x)=? ? f=[9, -5, 3, 7] ? g=[6, -1, 2]

Polynomial algebra • • f(x)/g(x)=? ? f=[9, -5, 3, 7] ? g=[6, -1, 2] ? [quotient, remainder]=deconv(f, g) quotient = %商式 1. 5000 -0. 5833 remainder = %餘式 0 0 -0. 5833 8. 1667 2/25/2021 Puff! The magic dragon, live by the sea… 75

Polynomial algebra • • • f(0), f(2), f(4), f(6), f(8), f(10) f(x)/g(x)=? ? a=[9,

Polynomial algebra • • • f(0), f(2), f(4), f(6), f(8), f(10) f(x)/g(x)=? ? a=[9, -5, 3, 7]; ? x=[0: 2: 10]; ? f=polyval(a, x); • or f=polyval([9, -5, 3, 7], [0: 2: 10]) 2/25/2021 Puff! The magic dragon, live by the sea… 76

Self testing • P. 108 2/25/2021 Puff! The magic dragon, live by the sea…

Self testing • P. 108 2/25/2021 Puff! The magic dragon, live by the sea… 77

2/25/2021 Puff! The magic dragon, live by the sea… 78

2/25/2021 Puff! The magic dragon, live by the sea… 78

2/25/2021 Puff! The magic dragon, live by the sea… 79

2/25/2021 Puff! The magic dragon, live by the sea… 79

2/25/2021 Puff! The magic dragon, live by the sea… 80

2/25/2021 Puff! The magic dragon, live by the sea… 80

Summary pp. 109 • Home work 2/25/2021 Puff! The magic dragon, live by the

Summary pp. 109 • Home work 2/25/2021 Puff! The magic dragon, live by the sea… 81

2/25/2021 Puff! The magic dragon, live by the sea… 82

2/25/2021 Puff! The magic dragon, live by the sea… 82

2/25/2021 Puff! The magic dragon, live by the sea… 83

2/25/2021 Puff! The magic dragon, live by the sea… 83