sec11 - CS100M Section Exercise 11 1 Two-dimensional...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS100M Section Exercise 11 1 Two-dimensional interpolation [Related to Project 5] In a simple case of one-dimensional interpolation, we add a data point between neigh- boring pairs of existing data points by taking the simple average. For example, 2.0 1.0 1.0 2.0 becomes 2.0 1.5 1.0 1.0 1.0 1.5 2.0 . In 2-d interpolation, work with one dimension at a time. For example, given a matrix 2.0 1.0 1.0 2.0 6.0 5.0 4.0 3.0 5.0 5.0 5.0 4.0 First we can add a column between two neighboring columns, so the matrix becomes 3 × 7: 2.0 1.5 1.0 1.0 1.0 1.5 2.0 6.0 5.5 5.0 4.5 4.0 3.5 3.0 5.0 5.0 5.0 5.0 5.0 4.5 4.0 Then add a row between neighboring rows, so the ±nal matrix will be 5 × 7: 2.0 1.5 1.0 1.0 1.0 1.5 2.0 4.0 3.5 3.0 2.8 2.5 2.5 2.5 6.0 5.5 5.0 4.5 4.0 3.5 3.0 5.5 5.2 5.0 4.8 4.5 4.0 3.5 5.0 5.0 5.0 5.0 5.0 4.5 4.0 Write two versions of the following function Interpolate2D : (a) use vectorized code (work with whole rows and/or whole columns) at a time; (b) use non-vectorized code. function newM = Interpolate2D(M)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online