You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

104 lines
4.3 KiB

function b_reg = fittingVolume()
rankk=5;
load('ETPMS_Vsample_abc.mat', 'V','aa', 'bb', 'cc')
num_a=size(aa,2);num_b=size(bb,2);num_c=size(cc,2);
v_vec = zeros(num_a*num_b*num_c,1);
a_vec = zeros(num_a*num_b*num_c,1);
b_vec = zeros(num_a*num_b*num_c,1);
c_vec = zeros(num_a*num_b*num_c,1);
idx=0;
for ia=1:num_a
a=aa(ia);
for ib=1:num_b
b=bb(ib);
for ic=1:num_c
c=cc(ic);
if 1+a+b+c>=0
idx=idx+1;
v_vec(idx) = V(ia,ib,ic);
a_vec(idx) = a;
b_vec(idx) = b;
c_vec(idx) = c;
end
end
end
end
disp(idx)
y=v_vec(1:idx);
x1=a_vec(1:idx);x2=b_vec(1:idx);x3=c_vec(1:idx);
if rankk==4
X = [ones(size(y)),...
x1, x2, x3,...
x1.^2, x2.^2, x3.^2, x1.*x2, x3.*x2, x1.*x3,...
x1.^3, x2.^3, x3.^3, x1.^2.*x2, x1.^2.*x3, x2.^2.*x1, x2.^2.*x3, x3.^2.*x1, x3.^2.*x2, x1.*x2.*x3,...
x1.^4, x1.^3.*x2, x1.^3.*x3,...
x2.^4, x2.^3.*x1, x2.^3.*x3,...
x3.^4, x3.^3.*x1, x3.^3.*x2,...
x1.^2.*x2.^2,x1.^2.*x3.^2,x3.^2.*x2.^2,...
x1.^2.*x2.*x3,x1.*x2.^2.*x3,x1.*x2.*x3.^2];
b_reg=regress(y,X);
yf = b_reg(1)+b_reg(2).*x1+b_reg(3).*x2+b_reg(4).*x3+...
b_reg(5).*x1.^2+b_reg(6).*x2.^2+b_reg(7).*x3.^2 ...
+b_reg(8).*x1.*x2+b_reg(9).*x3.*x2+b_reg(10).*x1.*x3...
+b_reg(11).*x1.^3+b_reg(12).*x2.^3+b_reg(13).*x3.^3 ...
+b_reg(14).*x1.^2.*x2+b_reg(15).*x1.^2.*x3+b_reg(16).*x2.^2.*x1 ...
+b_reg(17).*x2.^2.*x3+b_reg(18).*x3.^2.*x1+b_reg(19).*x3.^2.*x2 ...
+ b_reg(20).*x1.*x2.*x3 ...
+ b_reg(21).*x1.^4 + b_reg(22).*x1.^3.*x2 + b_reg(23).*x1.^3.*x3 ...
+ b_reg(24).*x2.^4 + b_reg(25).*x2.^3.*x1 + b_reg(26).*x2.^3.*x3 ...
+ b_reg(27).*x3.^4 + b_reg(28).*x3.^3.*x1 + b_reg(29).*x3.^3.*x2 ...
+ b_reg(30).*x1.^2.*x2.^2 + b_reg(31).*x1.^2.*x3.^2 + b_reg(32).*x3.^2.*x2.^2 ...
+ b_reg(33).*x1.^2.*x2.*x3 + b_reg(34).*x1.*x2.^2.*x3 + b_reg(35).*x1.*x2.*x3.^2;
end
if rankk==5
X = [ones(size(y)),...
x1, x2, x3,...
x1.^2, x2.^2, x3.^2, x1.*x2, x3.*x2, x1.*x3,...
x1.^3, x2.^3, x3.^3, x1.^2.*x2, x1.^2.*x3, x2.^2.*x1, x2.^2.*x3, x3.^2.*x1, x3.^2.*x2, x1.*x2.*x3,...
x1.^4, x1.^3.*x2, x1.^3.*x3,...
x2.^4, x2.^3.*x1, x2.^3.*x3,...
x3.^4, x3.^3.*x1, x3.^3.*x2,...
x1.^2.*x2.^2,x1.^2.*x3.^2,x3.^2.*x2.^2,...
x1.^2.*x2.*x3,x1.*x2.^2.*x3,x1.*x2.*x3.^2,...
x1.^5, x2.^5, x3.^5,...
x1.^4.*x2, x1.^4.*x3, x2.^4.*x1, x2.^4.*x3, x3.^4.*x1, x3.^4.*x2,...
x1.^3.*x2.*x3, x1.*x2.^3.*x3, x1.*x2.*x3.^3,...
x1.^2.*x2.^2.*x3, x1.*x2.^2.*x3.^2, x1.^2.*x2.*x3.^2,...
x1.^3.*x2.^2, x1.^3.*x3.^2, x2.^3.*x1.^2, x2.^3.*x3.^2, x3.^3.*x1.^2, x3.^3.*x2.^2];
b_reg=regress(y,X);
yf = b_reg(1)+b_reg(2).*x1+b_reg(3).*x2+b_reg(4).*x3+...
b_reg(5).*x1.^2+b_reg(6).*x2.^2+b_reg(7).*x3.^2 ...
+b_reg(8).*x1.*x2+b_reg(9).*x3.*x2+b_reg(10).*x1.*x3...
+b_reg(11).*x1.^3+b_reg(12).*x2.^3+b_reg(13).*x3.^3 ...
+b_reg(14).*x1.^2.*x2+b_reg(15).*x1.^2.*x3+b_reg(16).*x2.^2.*x1 ...
+b_reg(17).*x2.^2.*x3+b_reg(18).*x3.^2.*x1+b_reg(19).*x3.^2.*x2 ...
+ b_reg(20).*x1.*x2.*x3 ...
+ b_reg(21).*x1.^4 + b_reg(22).*x1.^3.*x2 + b_reg(23).*x1.^3.*x3 ...
+ b_reg(24).*x2.^4 + b_reg(25).*x2.^3.*x1 + b_reg(26).*x2.^3.*x3 ...
+ b_reg(27).*x3.^4 + b_reg(28).*x3.^3.*x1 + b_reg(29).*x3.^3.*x2 ...
+ b_reg(30).*x1.^2.*x2.^2 + b_reg(31).*x1.^2.*x3.^2 + b_reg(32).*x3.^2.*x2.^2 ...
+ b_reg(33).*x1.^2.*x2.*x3 + b_reg(34).*x1.*x2.^2.*x3 + b_reg(35).*x1.*x2.*x3.^2 ...
+ b_reg(36).*x1.^5 + b_reg(37).*x2.^5 + b_reg(38).*x3.^5 ...
+ b_reg(39).*x1.^4.*x2 + b_reg(40).*x1.^4.*x3 ...
+ b_reg(41).*x2.^4.*x1 + b_reg(42).*x2.^4.*x3 ...
+ b_reg(43).*x3.^4.*x1 + b_reg(44).*x3.^4.*x2 ...
+ b_reg(45).*x1.^3.*x2.*x3 + b_reg(46).*x1.*x2.^3.*x3 + b_reg(47).*x1.*x2.*x3.^3 ...
+ b_reg(48).*x1.^2.*x2.^2.*x3 + b_reg(49).*x1.*x2.^2.*x3.^2 + b_reg(50).*x1.^2.*x2.*x3.^2 ...
+ b_reg(51).*x1.^3.*x2.^2 + b_reg(52).*x1.^3.*x3.^2 + b_reg(53).*x2.^3.*x1.^2 ...
+ b_reg(54).*x2.^3.*x3.^2 + b_reg(55).*x3.^3.*x1.^2 + b_reg(56).*x3.^3.*x2.^2;
end
disp([' max abs. error: ',num2str(max(abs(yf-y)))])
disp(['mean abs. error: ',num2str(mean(abs(yf-y)))])
disp([' max rel. error: ',num2str(max(abs((yf-y)./y).*(y>0.02)))])
disp(['mean rel. error: ',num2str(mean(abs((yf-y)./y).*(y>0.02)))])
end