Professional Documents
Culture Documents
PowerPoint to accompany
Introduction to MATLAB
for Engineers, Third Edition
William J. Palm III
Chapter 7
Statistics, Probability,
and Interpolation
y
+
+
(xli, yli)
+
(x2, y2)
(x1, y1)
Copyright 2010. The McGraw-Hill Companies, Inc. This work is only for nonprofit use by instructors in courses for which this textbook has been adopted.
Any other use without publishers consent is unlawful.
Linear Interpolation
The interpolated value is determined solely on its relative
closeness to the known values:
In this example, li is closer to 2, so the contribution of 2
is greater:
Note that the length in the numerator is on the opposite
side of li to the y-value in that term:
Contribution
from 1
y
+
+
(xli, yli)
+
(x2, y2)
Contribution
from 2
(x1, y1)
x
The Study
Guide has
more forms
of the same
equation
7-28
More? See
pages 313-317.
7-29
7-30
Z_int = interp2(x,y,z,x_int,y_int)
7-31
>>x = [7,9,11,12];
>>y = [49,57,71,75];
>>x_int = 7:0.01:12;
>>y_int = spline(x,y,x_int);
>>plot(x,y,o,x,y,--,x_int,y_int),...
xlabel(Time (hr)),ylabel(Temperature
(deg F),...
title(Temperature Measurements at a
Single Location),...
axis([7 12 45 80])
This produces the next figure.
7-32
7-33
Command
y_int = spline(x,y,x_int)
y_est = interp1(x,y,x_est,spline)
Description
Returns a column vector y_est that contains the
estimated values of y that correspond to the x
values specified in the vector x_est, using
cubic-spline interpolation.
7-34
7-35
7-39
7-36
7-41