Presentation is loading. Please wait.

Presentation is loading. Please wait.

X is a matrix of size 4 x 2 (4 rows by 2 columns).

Similar presentations


Presentation on theme: "X is a matrix of size 4 x 2 (4 rows by 2 columns)."— Presentation transcript:

1 X is a matrix of size 4 x 2 (4 rows by 2 columns)

2 X is a matrix of size 2 x 3 (2 rows by 3 columns) Note the order how the matrix is filled The data vector with entries c(1,2,0,0,0,3) x 1,1 x 1,2 x 1,3 x 1,2 x 2,2 x 2,3 100 203 1, 2, 0, 0, 0, 3

3 X is a matrix of size 4 x 2 (4 rows by 2 columns) A matrix is a 2-dimensional array of data. We can plot 2-dimensional data arrays in R with the image() function using different colors for the entries in the matrix. image(X) Problems: (1)rows are ordered along x- axis, columns ordered along y-axis y x 1 2 3 4 5 6 7 8

4 X is a matrix of size 4 x 2 (4 rows by 2 columns) A matrix is a 2-dimensional array of data. We can plot 2-dimensional data arrays in R with the image() function using different colors for the entries in the matrix. image(t(X)) Problems: (2) The transpose function t(X) yields an up-side-down image of the matrix y x 1 2 3 4 5 6 7 8 1 4 3 2 8 7 6 5

5 To solve the problem and plot an image that orders the rows and columns exactly as defined in our matrix X: (1)Flip the transposed matrix such that rows are ‘up-side-down’: see updated scripts/myfunctions.R : matrix_flip_v(X) (2)And then use the transpose of the returned (‘up-side-down’) matrix in the image() plot function t(matrix_flip_v(X))

6

7 1 2 3 4 5 6 7 8 (1)In myfunctions.R there is a supporting function matrix_image() (2)Call res<-matrix_image(X) (Note: the function returns the transformed matrix)

8 demo_matrix_image.R Download the updated scripts myfunctions.R demo_matrix_image.R (data/labrador.ppm http://www.atmos.albany.edu/facstaff/timm/ATM315spring14/R/scripts/

9 Vectors in R: y<-c(x1,x2,x3,…xn)

10 R-Code: Another common notation for vector dot products Mathemathics: ‘magnitude’ or ‘length’ of a vector

11 Download the updated scripts demo_linear_trans.R demo_eigenvectors.R http://www.atmos.albany.edu/facstaff/timm/ATM315spring14/R/scripts/


Download ppt "X is a matrix of size 4 x 2 (4 rows by 2 columns)."

Similar presentations


Ads by Google