Sie sind auf Seite 1von 1

INTERPOLASI LINEAR

clear all;clc;
x = [1 3 5 7 9 ]; % x = beban yang bekerja pada struktur balok (t/m)
fx = [10 12 14 19 24]; % fx = diameter tulangan yang digunakan (mm)
cari = 4;
f4 = fx(1)+(fx(2)-fx(1))/(x(2)-x(1))*(cari-x(1))

INTERPOLASI KUADRATIK
clear all;clc;
x = [1 3 5 7 9];
fx = [10 12 14 19 24];
cari = 4;
b0 = fx(1);
b1 = (fx(2) - fx(1))/((x(2)-x(1)));
b2 = ((fx(3)-fx(2))/(x(3)-x(2))-((fx(2)-fx(1))/(x(2)-x(1))))/(x(3)-x(1));
f4 = b0 + (b1*(cari-x(1))) + (b2*(cari-x(1))*(cari-x(2)))

INTERPOLASI LAGRANGE
clear all;clc;
x = [1 3 5 7 9 ];
y = [10 12 14 19 24];
xcari = 4;
L = 0;
for i = 1:5;
pi=1;
for j=1:5;
if i~=j
pi=pi*(xcari-x(j))/(x(i)-x(j));
end
end
L = L+y(i)*pi;
end

disp(['Interpolasi Lagrange'])
disp(['Diameter Tulangan(',num2str(xcari),')=',num2str(L)])

Das könnte Ihnen auch gefallen