chapter9 - Chapter 9 The Second Dimension § 9.1 Rows and...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: Chapter 9 The Second Dimension § 9.1 Rows and Columns 2-dimensional arrays—matrix, functions that involve matrices, colon notation for submatrices, built-in function size § 9.2 Operations Searching a 2-dimensional array and updating its values, built-in functions rand and sprintf , subfunctions § 9.3 Tables in Two Dimensions Using 2-dimensional arrays to represent a function of two variables. As we have said before, the ability to think at the array level is very important in com- putational science. This is challenging enough when the arrays involved are linear, i.e., one- dimensional. Now we consider the two-dimensional array using this chapter to set the stage for more involved applications that use this structure. Two-dimensional array thinking is essential in application areas that involve image processing. (A digitized picture is a 2-dimensional ar- ray.) Moreover, many 3-dimensional problems are solved by solving a sequence of 2-dimensional, “cross-section” problems. We start by considering some array set-up computations in § 9.1. The idea is to develop an intuition about the parts of a 2-dimensional array: its rows, its columns, and its subarrays. Once an array is set up, it can be searched and its entries manipulated. Things are not too different from the 1-dimensional array setting, but we get additional row/column practice in § 9.2 by considering a look-for-the-max problem and also a mean/standard deviation calculation typical in data analysis. Computations that involve both 1- and 2-dimensional arrays at the same time are explored through a cost/purchase order/inventory application. Using a 2-dimensional array to store a finite snapshot of a 2-dimensional continuous function f ( x, y ) is examined in § 9.3. 9.1 Rows and Columns If f ( x ) is a function of a single variable, then a vector can be used to represent a table of its values. Until now, we have only dealt with 1-dimensional arrays. A single subscript is sufficient to specify the location of a value in a 1-dimensional array. 331 332 Chapter 9. The Second Dimension Many applications involve a function of two variables and a 2-dimensional array is often handy for the representation of its values. In Matlab , a 2-dimensional array is called a matrix . Our experience with 2-dimensional tables begins in grade school with the times table: 1 2 3 4 5 6 7 8 9 2 4 6 8 10 12 14 16 18 3 6 9 12 15 18 21 24 27 4 8 12 16 20 24 28 32 36 5 10 15 20 25 30 35 40 45 6 12 18 24 30 36 42 48 54 7 14 21 28 35 42 49 56 63 8 16 24 32 40 48 56 64 72 9 18 27 36 45 54 63 72 81 Times table construction is shown in Example9 1 which illustrates the creation of a matrix and the printing of a sub matrix. The integers r1 and r2 define the range of the involved rows while c1 and c2 specify the column range. Extending our colon notation in the obvious way, we see that Example9 1 displays the 4-by-6 subarray T(6:9,5:10) ....
View Full Document

This note was uploaded on 09/23/2007 for the course COM S 100 taught by Professor Fan/chew during the Spring '07 term at Cornell University (Engineering School).

Page1 / 23

chapter9 - Chapter 9 The Second Dimension § 9.1 Rows and...

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

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