This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Chapter 9 The Second Dimension § 9.1 Rows and Columns 2dimensional arrays—matrix, functions that involve matrices, colon notation for submatrices, builtin function size § 9.2 Operations Searching a 2dimensional array and updating its values, builtin functions rand and sprintf , subfunctions § 9.3 Tables in Two Dimensions Using 2dimensional 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 twodimensional array using this chapter to set the stage for more involved applications that use this structure. Twodimensional array thinking is essential in application areas that involve image processing. (A digitized picture is a 2dimensional ar ray.) Moreover, many 3dimensional problems are solved by solving a sequence of 2dimensional, “crosssection” problems. We start by considering some array setup computations in § 9.1. The idea is to develop an intuition about the parts of a 2dimensional 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 1dimensional array setting, but we get additional row/column practice in § 9.2 by considering a lookforthemax problem and also a mean/standard deviation calculation typical in data analysis. Computations that involve both 1 and 2dimensional arrays at the same time are explored through a cost/purchase order/inventory application. Using a 2dimensional array to store a finite snapshot of a 2dimensional 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 1dimensional arrays. A single subscript is sufficient to specify the location of a value in a 1dimensional array. 331 332 Chapter 9. The Second Dimension Many applications involve a function of two variables and a 2dimensional array is often handy for the representation of its values. In Matlab , a 2dimensional array is called a matrix . Our experience with 2dimensional 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 4by6 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).
 Spring '07
 FAN/CHEW
 Derivative, Array, Continuous function, builtin function

Click to edit the document details