1 / 15

Philosophiae Naturalis Principia Matlab ematica

Philosophiae Naturalis Principia Matlab ematica. Damian Gordon. Getting to Matlab. 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.

yakov
Download Presentation

Philosophiae Naturalis Principia Matlab ematica

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Philosophiae Naturalis Principia Matlabematica Damian Gordon

  2. Getting to Matlab

  3. 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,...

  4. Identity Function >> eye (4) ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

  5. Upper Triangle Matrix » 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 » 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

  6. Lower Triangle Matrix » 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 » 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

  7. 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

  8. Inverse Hilbert Matrix » invhilb(4) ans = 16 -120 240 -140 -120 1200 -2700 1680 240 -2700 6480 -4200 -140 1680 -4200 2800

  9. 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

  10. 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

  11. Dot Operator • A = magic(4); b=ones(4); • A * B • A.*B • the dot operator performs element-by-element operations, for “*”, “\” and “/”

  12. 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 !!

  13. 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)

  14. 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

  15. 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

More Related