MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of
MATLAB Mathematics - SERC - Index of
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Interpolation<br />
the relevant function at the points specified by xi. This is the default method<br />
for the interp1 function.<br />
• Cubic spline interpolation (method = 'spline'). This method fits a different<br />
cubic function between each pair <strong>of</strong> existing data points, and uses the spline<br />
function to perform cubic spline interpolation at the data points.<br />
• Cubic interpolation (method = 'pchip' or 'cubic'). These methods are<br />
identical. They use the pchip function to perform piecewise cubic Hermite<br />
interpolation within the vectors x and y. These methods preserve<br />
monotonicity and the shape <strong>of</strong> the data.<br />
If any element <strong>of</strong> xi is outside the interval spanned by x, the specified<br />
interpolation method is used for extrapolation. Alternatively,<br />
yi = interp1(x,Y,xi,method,extrapval) replaces extrapolated values with<br />
extrapval. NaN is <strong>of</strong>ten used for extrapval.<br />
All methods work with nonuniformly spaced data.<br />
Speed, Memory, and Smoothness Considerations<br />
When choosing an interpolation method, keep in mind that some require more<br />
memory or longer computation time than others. However, you may need to<br />
trade <strong>of</strong>f these resources to achieve the desired smoothness in the result:<br />
• Nearest neighbor interpolation is the fastest method. However, it provides<br />
the worst results in terms <strong>of</strong> smoothness.<br />
• Linear interpolation uses more memory than the nearest neighbor method,<br />
and requires slightly more execution time. Unlike nearest neighbor<br />
interpolation its results are continuous, but the slope changes at the vertex<br />
points.<br />
• Cubic spline interpolation has the longest relative execution time, although<br />
it requires less memory than cubic interpolation. It produces the smoothest<br />
results <strong>of</strong> all the interpolation methods. You may obtain unexpected results,<br />
however, if your input data is non-uniform and some points are much closer<br />
together than others.<br />
• Cubic interpolation requires more memory and execution time than either<br />
the nearest neighbor or linear methods. However, both the interpolated data<br />
and its derivative are continuous.<br />
The relative performance <strong>of</strong> each method holds true even for interpolation <strong>of</strong><br />
two-dimensional or multidimensional data. For a graphical comparison <strong>of</strong><br />
2-11