Curve Fitting
Curve Fitting
Curve Fitting
05 Curve Fitting
Introduction
discrete values.
• This Chapter describes techniques to fit
curves to such data to obtain intermediate
estimates.
• There are two general approaches for curve
fitting that are distinguished from each
other on the basis of the amount of error
05 Curve Fitting
the data.
• Because any individual data point may be
incorrect, we make no effort to intersect
every point. Rather, the curve is designed to
follow the pattern of the points taken as a
group. One approach of this nature is called
least-squares regression
Interpolation
points.
• Such data usually originate from tables.
Examples are values for the density of water
or for the heat capacity of gases as a
function of temperature.
• The estimation of values between well-
known discrete points is called interpolation
Three attempts to fit a
“best” curve through
five data points:
05 Curve Fitting
(a) least-squares
regression,
(b) linear interpolation,
(c) curvilinear
interpolation.
5.1. Regression
a. Linear Regression
• The primary objective of this method is to
how least-squares regression can be used to
05 Curve Fitting
as in
Examples of some criteria
for “best fit” that are
inadequate for regression:
05 Curve Fitting
residuals:
• To determine values for a0 and a1, Eq. above is
differentiated with respect to each unknown coefficient:
05 Curve Fitting
• These are called the normal equations. They
can be solved simultaneously for
05 Curve Fitting
Problem
p (torr) 1 5 10 20 40 60
b
p exp a
T 273,2
b
05 Curve Fitting
ln(p) = a +
T 273,2
y=a+bx
1
y = ln(p) dan x =
T 273,2
lanjutan
% Data - data
p = [ 1 5 10 20 40 60]; % C
T = [-26.7 -4.4 6.4 18.4 31.8 40.3]; % Torr
05 Curve Fitting
% Linierisasi
y = log(p);
x = 1./(T+273.15);
kons = polyfit(x,y,1);
a = kons(2)
b = kons(1)
Regresi Polinomial
data-data didekati dengan persamaan
polinomial, yaitu :
y = a0 + a1x + a2x2 + .... + amxm
05 Curve Fitting
lanjutan
Fungsi polyfit dari Matlab dapat
digunakan untuk derajat n = 2, yang disebut
polinomial kuadratis. Hasil fungsi
05 Curve Fitting
-36,7 1 15,4 60
-19,6 5 26,1 100
-11,5 10 42,2 200
-2,6 20 60,6 400
7,6 40 80,1 760
Hubungan tekanan sebagai fungsi temperatur dapat dinyatakan
sebagai persamaan empiris polinomial sederhana sebagai berikut :
P = a0 + a1T + a2T2 + a3T3 + … + anTn
dengan a0, a1, …, an adalah parameter yang ditentukan dengan regresi
dan n adalah orde polinomial.
lanjutan
vp = [ 1 5 10 20 40 60 100 200 400 760];
T =[-36.7 -19.6 -11.5 -2.6 7.6 15.4 26.1
42.2 60.6 80.1];
05 Curve Fitting
Newton linear-
interpolation formula.
• Find ρ, μ, and v at T = 27 oC
05 Curve Fitting
b. Quadratic Interpolation
• A strategy for improving the estimate is to introduce some
curvature into the line connecting the points. If three data
points are available, this can be accomplished with a
05 Curve Fitting
The methode
‘nearest‘-
‘linier‘-
‘spline‘-
‘cubic‘ -
Konduktivitas termal aseton
Bennett & Meyers memberikan data-data konduktivitas
termal aseton. Hubungan ln (k) dan ln (T) mendekati
05 Curve Fitting
0,0074 115
0,0099 212
0,0147 363
lanjutan
k = [0.0057 0.0074 0.0099 0.0147];
T = [32 115 212 363]+460;
% Hubungan k dan T linier
05 Curve Fitting
ln_k = log(k);
ln_T = log(T);
% Interpolasi Linier
T300 = log(300+460);
k300 = interp1(ln_T,ln_k,T300,'linier');
% Hasil
k_pd_300 = exp(k300)
b. Splines Interpolation
• nth-order polynomials were used to interpolate between
(n+1) data points.
• For example, for eight points, we can derive a perfect
05 Curve Fitting
% Kondisi akhir
Tn = [400 500]; % Temperatur, oF
pn = [50 55]; % Tekanan, psia
Hn = [1258.7 1282.6
1258.2 1282.2]; % Entalphi, BTU/lb
H2 = interp2(Tn,pn,Hn,480,52) % Interpolasi 2 dimensi