COM S
chapter9

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

• Notes
• 23

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

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

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

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) .
This is the end of the preview. Sign up to access the rest of the document.
• Spring '07
• FAN/CHEW
• Derivative, Array, Continuous function, built-in function

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern