Professional Documents
Culture Documents
Chio Code
Chio Code
60];
x = [31.8; 31.5; 31.2; 30.2];
w = [log(2.4); log(3.8); log(4.75); log(21.60)];
A = 0; B = 0; C = 0; D = 0; E = 0; F = 0;
% A = summation of wy/(x-b)^c
for i = 1:4
A = (w(i)*y(i) / (x(i)-b)^c) + A;
end
% B = summation of 1/(x-b)^(2*c)
for i = 1:4
B = (1/(x(i)-b)^(2*c)) + B;
end
% C = summation of 1/(x-b)^((2*c)+1)
for i = 1:4
C = (1/(x(i)-b)^((2*c)+1)) + C;
end
% D = summation of wy/(x-b)^(c+1)
for i = 1:4
D = (w(i)*y(i)/((x(i)-b)^(c+1))) + D;
end
% E = summation of log(x-b)/(x-b)^(2*c)
for i = 1:4
E = (log(x(i)-b)/((x(i)-b)^(2*c))) + E;
end
% F = summation of wylog(x-b)/(x-b)^c
for i = 1:4
F = (w(i)*y(i)*log(x(i)-b)/(x(i)-b)^c) + F;
end
f1 = (A*C) - (D*B);
f2 = (A*E) - (F*B);
L = diff(f1,b);
M = diff(f2,b);
N = diff(f1,c);
O = diff(f2,c);
J = [L M; N O];
syms b c
% Solve for a
G = 0;
H = 0;
for i = 1:4
G = ((w(i)*y(i))/(x(i) - bnew)^(2*cnew)) + G;
end
for i = 1:4
H = (1/(x(i)-bnew)^(2*cnew)) + H;
end
a = G/H;
disp('a = '); disp(a);