This preview shows page 1. Sign up to view the full content.
CS100M Section Exercise 11
1
Twodimensional interpolation
[Related to Project 5]
In a simple case of onedimensional 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 2d 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 nonvectorized code.
function newM = Interpolate2D(M)
This is the end of the preview. Sign up
to
access the rest of the document.
 Fall '07
 FAN/VANLOAN

Click to edit the document details