MATLAB Programming

MATLAB Programming MATLAB Programming

cda.psych.uiuc.edu
from cda.psych.uiuc.edu More from this publisher
23.06.2015 Views

1 Data Structures Multidimensional Arrays An array having more than two dimensions is called a multidimensional array in MATLAB. Most of the operations that you can perform on matrices (i.e., two-dimensional arrays) can also be done on multidimensional arrays. This section shows how to create and manipulate these arrays. It covers • “Overview” on page 1-52 • “Creating Multidimensional Arrays” on page 1-54 • “Accessing Multidimensional Array Properties” on page 1-57 • “Indexing Multidimensional Arrays” on page 1-58 • “Reshaping Multidimensional Arrays” on page 1-62 • “Permuting Array Dimensions” on page 1-64 • “Computing with Multidimensional Arrays” on page 1-66 • “Organizing Data in Multidimensional Arrays” on page 1-67 • “Multidimensional Cell Arrays” on page 1-69 • “Multidimensional Structure Arrays” on page 1-70 Overview Multidimensional arrays in MATLAB are an extension of the normal two-dimensional matrix. Matrices have two dimensions: the row dimension and the column dimension. You can access a two-dimensional matrix element with two subscripts: the first representing the row index, and the second representing the column index. 1-52

Multidimensional Arrays Multidimensional arrays use additional subscripts for indexing. A three-dimensional array, for example, uses three subscripts: • The first references array dimension 1, the row. • The second references dimension 2, the column. • The third references dimension 3. This illustration uses the concept of a page to represent dimensions 3 and higher. To access the element in the second row, third column of page 2, for example, you use the subscripts (2,3,2). 1-53

Multidimensional Arrays<br />

Multidimensional arrays use additional subscripts for indexing. A<br />

three-dimensional array, for example, uses three subscripts:<br />

• The first references array dimension 1, the row.<br />

• The second references dimension 2, the column.<br />

• The third references dimension 3. This illustration uses the concept of a<br />

page to represent dimensions 3 and higher.<br />

To access the element in the second row, third column of page 2, for example,<br />

you use the subscripts (2,3,2).<br />

1-53

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!