Philosophiae Naturalis Principia Matlab ematica Damian Gordon.
-
Upload
christiana-jordan -
Category
Documents
-
view
214 -
download
0
Transcript of Philosophiae Naturalis Principia Matlab ematica Damian Gordon.
![Page 1: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/1.jpg)
Philosophiae Naturalis Principia Matlabematica
Damian Gordon
![Page 2: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/2.jpg)
Getting to Matlab
![Page 3: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/3.jpg)
Magic Matrix
MAGIC Magic square.
MAGIC(N) is an N-by-N matrix constructed from the integers
1 through N^2 with equal row, column, and diagonal sums.
Produces valid magic squares for N = 1,3,4,5,...
![Page 4: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/4.jpg)
Identity Function
>> eye (4)
ans =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
![Page 5: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/5.jpg)
Upper Triangle Matrix
» a = ones(5)
a =
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
» triu(a)
ans =
1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 0 0 0 0 1
![Page 6: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/6.jpg)
Lower Triangle Matrix
» a = ones(5)
a =
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
» tril(a)
ans =
1 0 0 0 0 1 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1
![Page 7: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/7.jpg)
Hilbert Matrix» hilb(4)
ans =
1.0000 0.5000 0.3333 0.2500
0.5000 0.3333 0.2500 0.2000
0.3333 0.2500 0.2000 0.1667
0.2500 0.2000 0.1667 0.1429
![Page 8: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/8.jpg)
Inverse Hilbert Matrix» invhilb(4)
ans =
16 -120 240 -140
-120 1200 -2700 1680
240 -2700 6480 -4200
-140 1680 -4200 2800
![Page 9: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/9.jpg)
Toeplitz matrix.
TOEPLITZ
TOEPLITZ(C,R) is a non-symmetric Toeplitz matrix having C as its
first column and R as its first row.
TOEPLITZ(R) is a symmetric (or Hermitian) Toeplitz matrix.
-> See also HANKEL
![Page 10: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/10.jpg)
Summary of Functions
• magic• eye(4)• triu(4)• tril(4)• hilb(4)• invhilb(4) • toeplitz(4)
- magic matrix
- identity matrix
- upper triangle
- lower triangle
- hilbert matrix
- Inverse Hilbert matrix
- non-symmetric Toeplitz matrix
![Page 11: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/11.jpg)
Dot Operator
• A = magic(4); b=ones(4);
• A * B
• A.*B
• the dot operator performs element-by-element operations, for “*”, “\” and “/”
![Page 12: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/12.jpg)
Concatenation
• To create a large matrix from a group of smaller ones
• try– A = magic(3)– B = [ A, zeros(3,2) ; zeros(2,3), eye(2)]– C = [A A+32 ; A+48 A+16]– Try some of your own !!
![Page 13: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/13.jpg)
Subscripts
• Row i and Column j of matrix A is denoted by A(i,j)
• A = Magic(4)
• try– A(1,4) + A(2,4) + A(3,4) + A(4,4)
• try– A(4,5)
![Page 14: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/14.jpg)
The Colon Operator (1)
• This is one MatLab’s most important operators
• 1:10 means the vector– 1 2 3 4 5 6 7 8 9 10
• 100:-7:50– 100 93 86 79 72 65 58 51
• 0:pi/4:pi– 0 0.7854 1.5708 2.3562 3.1416
![Page 15: Philosophiae Naturalis Principia Matlab ematica Damian Gordon.](https://reader036.fdocuments.us/reader036/viewer/2022082713/5697bf9e1a28abf838c9417e/html5/thumbnails/15.jpg)
The Colon Operator (2)
• The first K elements in the jth column is– A(1:K, j)
• Sum(A(1:4, 4)) is the sum of the 4th column
or
• Sum(A(:, 4)) means the same