P.Lecture - 2.19.08 - Announcements Assignment 3 Exam 1...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
Announcements • Assignment 3 •E xam 1 –G raded –Ba ck in recitations on Friday – Statistics on Thursday (hopefully) •Read Chapters 11,12, 13 and 22 •Top i c s for today –Ma t r i ce s – Random numbers –S t r ing s (time permitting)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Review: 2D Arrays • Used for tables and matrices •De c la ra t ion similar to one dimensional arrays y • Need to specify both the number of rows and columns during allocation •Fo r example: int myMatrix [10] [10]; double energyTable [5] [6]; char conversionTable [26] [26];
Background image of page 2
Matrix operations •C does not have a primitive matrix data type ’s treated as a 2 array – It s treated as a 2 D array Common matrix operations must be rogrammed! programmed! •Matr ix transpose, inversion, addition, multiplication, etc. –C is not MATLAB – More on matrix operations later 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What is a Matrix? •A matrix is a set of elements, organized into rows d columns and columns A is a 2 X 2 matrix 2 columns 1 0 a a 11 10 01 00 a a 2 rows
Background image of page 4
Matrices •3x3 Matrix A looks like 23 22 21 13 12 11 a a a a a a A = 33 32 31 a a a a ij refers to the element of matrix A in i th row and j th column • Most common operations are: –Unary : transpose, inverse – Binary: addition, multiplication
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Transpose •Swap the rows with the columns c b a g d a = f e d M = h e b M T i h g i f c n X r then T r X n If M is n X r then M is r X n
Background image of page 6
Matrix Addition + + f b e a f e b a + + = + h d g c h g d c Just add the corresponding elements urce matrices must be of the me order source matrices must be of the same order For example 1 1 A = 1 1 2 1 B = -1 3 3 2 C=A+B = 0 4 1 1 0 -2 1 -1
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Matrix Addition + You can also add a scalar to a matrix: 1 5 1 A = 1 1 B = A + 4 = 1 1 5 5 5 5 5 multiply a matrix by a scalar: 2 4 A = 4 6 B = A * 2 = 3 4 8 8 12 6 1 2 atrix subtraction is done similar to addition Matrix subtraction is done similar to addition
Background image of page 8
Matrix Multiplication + + = h g bh af bg ae f
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2008 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas at Austin.

Page1 / 22

P.Lecture - 2.19.08 - Announcements Assignment 3 Exam 1...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online