Data tabulasi jumlah penduduk Purworejo
Tahun 2000 2010
Jumlah Penduduk 187900 205700
SOURCE CODE
function y=f(x0,y0,x1,y1,x)
y=y0+((y1-y0)/(x1-x0))*(x-x0);
endfunction
x0=2000;
y0=187900;
x1=2010;
y1=205700;
j=1;
for i=x0-5:0.1:x1+5
tx(j)=i;
ty(j)=f(x0,y0,x1,y1,i);
j=j+1;
end
plot(tx,ty);
plot(x0,y0,'or');
plot(x1,y1,'og');
INTERPOLASI KUADRATIK
Data tabulasi jumlah penduduk Purworejo
Tahun 2000 2010 2012
Jumlah Penduduk 180700 205700 190000
SOURCE CODE
function y=f(x0,y0,x1,y1,x2,y2,x)
y=(y1*(((x-x1)*(x-x2))/((x0-x1)*(x0-x2))))+(y1*(((x-x0)*(x-x2))/((x1-x0)*(x1-x2))))+(y2*(((x-x0)*(x-x1))/((x2-x0)*(x2-x1))));
endfunction
x0=2000;
y0=180700;
x1=2010;
y1=205700;
x2=2012;
y2=190000;
j=1;
for i=x0-60:0.01:x2+20
tx(j)=i;
ty(j)=f(x0,y0,x1,y1,x2,y2,i);
j=j+1;
end
plot(tx,ty);
plot(x0,y0,'or');
plot(x1,y1,'og');
plot(x2,y2,'ob');
INTERPOLASI KUBIK
Data tabulasi jumlah penduduk Purworejo
Tahun 2000 2010 2012 2015
Jumlah Penduduk 187900 205700 190000 210000
SOURCE CODE
function y=f(x0,y0,x1,y1,x2,y2,x3,y3,x)
y=(y0*((x-x1)*(x-x2)*(x-x3))/((x0-x1)*(x0-x2)*(x0-x3)))+(y1*((x-x0)*(x-x2)*(x-x3))/((x1-x0)*(x1-x2)*(x1-x3)))+(y2*((x-x0)*(x-x1)*(x-x3))/((x2-x0)*(x2-x1)*(x2-x3)))+(y3*((x-x0)*(x-x1)*(x-x2))/((x3-x0)*(x3-x1)*(x3-x2)));
endfunction
x0=1;
y0=10;
x1=5;
y1=10;
x2=9;
y2=18;
x3=15;
y3=24;
j=1;
for i=x0-5:0.1:x3+5
tx(j)=i;
ty(j)=f(x0,y0,x1,y1,x2,y2,x3,y3,i);
j=j+1;
end
plot(tx,ty);
plot(x0,y0,'or');
plot(x1,y1,'og');
plot(x2,y2,'ob');
plot(x3,y3,'oy');