You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
148 Applications<br />
fiii§Jifil One-dimensional data interpolation, i.e., given Yi at xi, finds Y] at<br />
desired Xj from '!/j = j(xj). Here f is a continuous function that is found from<br />
interpolation. It is called one-dimensional interpolation because y depends on<br />
a single variable :r.<br />
The calling syntax is<br />
ynew =<br />
interp1(x,y,xnew ,method)<br />
where method is an optional argument discussed after the descriptions of<br />
interp2 and interp3.<br />
Ellf§Jiti Two-dimensional data interpolation, i.e., given zi at (xi, Yi), finds Zj at<br />
desired (xj,yj) from z = j(x, y). The function f is found from interpolation.<br />
It is called two-dimenl:lional interpolation because z depends on two variables,<br />
x and y.<br />
znew = interp2 (x,y,z,xnew, ynew ,method) .<br />
lfii§iiJ Three-dimensional analogue of interp1, i.e. , given Vi at (xi, Yi, zi) ,<br />
finds Vj at desired (xj,yj,Zj)·<br />
vnew = interp3(x,y,z,v,xnew,ynew, znew,method) .<br />
In addition, there is an n-dimensional analogue, interpn, if you ever need it.<br />
In each function, you have an option of specifying a method of interpolation. The<br />
choices for method are nearest, linear, cubic, or spline. The choice of the method<br />
dictates the smoothness of the interpolated data. The default method is linear.<br />
To specify cubic interpolation instead of linear, for example, in interp1, use the<br />
syntax<br />
ynew = interp1 (x,y,xnew, ' cubic').<br />
The example at the end of this section shows how to use interp1. It also<br />
compares results obtained from different interpolation methods.<br />
There are some other important interpolation functions worth mentioning:<br />
ynew = spline (x,y,xnew,method) .<br />
There are other variants of the calling syntax. It is also possible to get the<br />
coefficients of the interpolated cubic polynomial segments that can be used<br />
later. Sec the on-line help.<br />
ilri§i•ijl Fast Pourier transform (FFT)-based 1-D clfl.t,n interpolation. This<br />
is similar to interp1 except lhat lhe data is interpolated first <strong>by</strong> taking the<br />
Fourier transform of the given data and then calculating the inverse Lransform<br />
using more data points. This interpolation is especially useful for periodic<br />
functions (i.e., if values of y are periodic). See the on-line help.