0% found this document useful (0 votes)
106 views1 page

Array or Matrix Layout

The document discusses the differences between array layout and matrix layout for multi-dimensional data. Array layout corresponds the first index (i) to the x-coordinate and the second index (j) to the y-coordinate. Matrix layout corresponds the first index (i) to the y-coordinate and the second index (j) to the x-coordinate. MATLAB uses matrix layout by default, while array layout is more logical but requires using a for-loop to vectorize the data. Checking if data is in array layout involves assigning the first column of x and y to variables to test the index correspondence.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views1 page

Array or Matrix Layout

The document discusses the differences between array layout and matrix layout for multi-dimensional data. Array layout corresponds the first index (i) to the x-coordinate and the second index (j) to the y-coordinate. Matrix layout corresponds the first index (i) to the y-coordinate and the second index (j) to the x-coordinate. MATLAB uses matrix layout by default, while array layout is more logical but requires using a for-loop to vectorize the data. Checking if data is in array layout involves assigning the first column of x and y to variables to test the index correspondence.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CI2-221 Computational Methods

Is is ARRAY LAYOUT or is it MATRIX LAYOUT?


Remember: The i index stands for number of rows (the number of rows is a vertical property) The j index stands for number of columns (the number of columns is a horizontal property)

Array Layout
Array layout is when: the x-coordinate corresponds to the first index i (each row has the same number throughout) the y-coordinate corresponds to the second index j (each column has the same number throughout) x-coordinate 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 y-coordinate 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8

Remember: Array layout is pretty logical x corresponds to i and y corresponds to j as it always has.

Matrix Layout
Matrix layout is when: the x-coordinate corresponds to the second index j (each column has the same number throughout) the y-coordinate corresponds to the first index i (each row has the same number throughout) x-coordinate 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5 6 6 6 6 6 6 6 6 6 7 7 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 y-coordinate 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8 0 1 2 3 4 5 6 7 8

Remember: Matrix layout is the MATLAB default layout and we need to vectorize the data into array layout by using a for-loop. The intrinsic function meshgrid produces a grid in matrix layout. This system can also be the relationship between y and z coordinates instead of x and y (in Tutorial 4) To check if something is in array layout: X = x(:,1); Y = y(:,1); (to see if x corresponds to the first index) (to see if y corresponds to the second index)

You might also like